本文整理汇总了C#中SolrQueryExecuter.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# SolrQueryExecuter.Execute方法的具体用法?C# SolrQueryExecuter.Execute怎么用?C# SolrQueryExecuter.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolrQueryExecuter
的用法示例。
在下文中一共展示了SolrQueryExecuter.Execute方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute()
{
const string queryString = "id:123456";
var q = new Dictionary<string, string>();
q["q"] = queryString;
var conn = new MockConnection(q);
var mocks = new MockRepository();
var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
var mockR = mocks.DynamicMock<SolrQueryResults<TestDocument>>();
var serializer = mocks.StrictMock<ISolrQuerySerializer>();
With.Mocks(mocks).Expecting(() => {
Expect.On(parser)
.Call(parser.Parse(null))
.IgnoreArguments()
.Repeat.Once()
.Return(mockR);
Expect.On(serializer)
.Call(serializer.Serialize(null))
.IgnoreArguments()
.Repeat.Once()
.Return(queryString);
}).Verify(() => {
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, serializer, null, null);
var r = queryExecuter.Execute(new SolrQuery(queryString), null);
});
}
示例2: Execute
public void Execute() {
const string queryString = "id:123456";
var q = new Dictionary<string, string>();
q["q"] = queryString;
var conn = new MockConnection(q);
var serializer = new MSolrQuerySerializer();
serializer.serialize += _ => queryString;
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Stub();
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, serializer, null, null);
var r = queryExecuter.Execute(new SolrQuery(queryString), null);
Assert.AreEqual(1, serializer.serialize.Calls);
}
示例3: Sort
public void Sort() {
const string queryString = "id:123456";
var q = new Dictionary<string, string>();
q["q"] = queryString;
q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
q["sort"] = "id asc";
var conn = new MockConnection(q);
var querySerializer = new SolrQuerySerializerStub(queryString);
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Expect(1);
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
OrderBy = new[] { new SortOrder("id") }
});
parser.parse.Verify();
}
示例4: tt
public void tt()
{
var mocks = new MockRepository();
var connection = mocks.StrictMock<ISolrConnection>();
var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
With.Mocks(mocks).Expecting(delegate {
Expect.Call(connection.Get(null, null))
.IgnoreArguments()
.Repeat.Once()
.Return("");
Expect.Call(parser.Parse(null))
.IgnoreArguments()
.Repeat.Once()
.Return(new SolrQueryResults<TestDocument>());
}).Verify(delegate {
var q = new SolrQueryExecuter<TestDocument>(parser, connection, null, null);
var r = q.Execute(new SolrQuery("id:123456"), null);
});
}
示例5: ResultFields
public void ResultFields()
{
const string queryString = "id:123456";
var q = new Dictionary<string, string>();
q["q"] = queryString;
q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
q["fl"] = "id,name";
var conn = new MockConnection(q);
var querySerializer = new SolrQuerySerializerStub(queryString);
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Stub();
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
Fields = new[] { "id", "name" },
});
}
示例6: MultipleFacetFields
public void MultipleFacetFields()
{
var conn = new MockConnection(new[] {
KV.Create("q", ""),
KV.Create("rows", SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString()),
KV.Create("facet", "true"),
KV.Create("facet.field", "Id"),
KV.Create("facet.field", "OtherField"),
});
var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
var facetQuerySerializer = new DefaultFacetQuerySerializer(serializer, new DefaultFieldSerializer());
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Stub();
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, serializer, facetQuerySerializer, null);
queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
Facet = new FacetParameters {
Queries = new ISolrFacetQuery[] {
new SolrFacetFieldQuery("Id"),
new SolrFacetFieldQuery("OtherField"),
}
}
});
}
示例7: Highlighting
public void Highlighting()
{
const string highlightedField = "field1";
const string afterTerm = "after";
const string beforeTerm = "before";
const int snippets = 3;
const string alt = "alt";
const int fragsize = 7;
var q = new Dictionary<string, string>();
q["q"] = "";
q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
q["hl"] = "true";
q["hl.fl"] = highlightedField;
q["hl.snippets"] = snippets.ToString();
q["hl.fragsize"] = fragsize.ToString();
q["hl.requireFieldMatch"] = "true";
q["hl.alternateField"] = alt;
q["hl.tag.pre"] = beforeTerm;
q["hl.tag.post"] = afterTerm;
q["hl.regex.slop"] = "4.12";
q["hl.regex.pattern"] = "\\.";
q["hl.regex.maxAnalyzedChars"] = "8000";
q["hl.usePhraseHighlighter"] = "true";
q["hl.useFastVectorHighlighter"] = "true";
q["hl.highlightMultiTerm"] = "true";
q["hl.mergeContiguous"] = "true";
q["hl.maxAnalyzedChars"] = "12";
q["hl.maxAlternateFieldLength"] = "22";
q["hl.fragmenter"] = "regex";
var conn = new MockConnection(q);
var querySerializer = new SolrQuerySerializerStub("");
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Stub();
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
Highlight = new HighlightingParameters {
Fields = new[] { highlightedField },
AfterTerm = afterTerm,
BeforeTerm = beforeTerm,
Snippets = snippets,
AlternateField = alt,
Fragsize = fragsize,
RequireFieldMatch = true,
RegexSlop = 4.12,
RegexPattern = "\\.",
RegexMaxAnalyzedChars = 8000,
UsePhraseHighlighter = true,
UseFastVectorHighlighter = true,
MergeContiguous = true,
MaxAnalyzedChars = 12,
HighlightMultiTerm = true,
MaxAlternateFieldLength = 22,
Fragmenter = SolrHighlightFragmenter.Regex
}
});
}
示例8: FilterQuery
public void FilterQuery()
{
var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
var conn = new MockConnection(new[] {
KV.Create("q", "*:*"),
KV.Create("rows", "10"),
KV.Create("fq", "id:0"),
KV.Create("fq", "id:2"),
});
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Stub();
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null) {
DefaultRows = 10,
};
queryExecuter.Execute(SolrQuery.All, new QueryOptions {
FilterQueries = new[] {
new SolrQuery("id:0"),
new SolrQuery("id:2"),
},
});
}
示例9: Facets
public void Facets()
{
var q = new Dictionary<string, string>();
q["q"] = "";
q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
q["facet"] = "true";
q["facet.field"] = "Id";
q["facet.query"] = "id:[1 TO 5]";
var conn = new MockConnection(q);
var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Stub();
var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, new DefaultFieldSerializer());
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, facetQuerySerializer, null);
queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
Facet = new FacetParameters {
Queries = new ISolrFacetQuery[] {
new SolrFacetFieldQuery("Id"),
new SolrFacetQuery(new SolrQuery("id:[1 TO 5]")),
}
}
});
}
示例10: HighlightingWithoutFieldsOutputsPrePost
public void HighlightingWithoutFieldsOutputsPrePost() {
const string afterTerm = "after";
const string beforeTerm = "before";
var q = new Dictionary<string, string>();
q["q"] = "";
q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
q["hl"] = "true";
q["hl.tag.pre"] = beforeTerm;
q["hl.tag.post"] = afterTerm;
q["hl.useFastVectorHighlighter"] = "true";
var conn = new MockConnection(q);
var querySerializer = new SolrQuerySerializerStub("");
var parser = new MSolrAbstractResponseParser<TestDocument>();
parser.parse &= x => x.Stub();
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
queryExecuter.Execute(new SolrQuery(""), new QueryOptions {
Highlight = new HighlightingParameters {
AfterTerm = afterTerm,
BeforeTerm = beforeTerm,
UseFastVectorHighlighter = true,
}
});
}
示例11: SortMultipleWithOrders
public void SortMultipleWithOrders()
{
const string queryString = "id:123456";
var q = new Dictionary<string, string>();
q["q"] = queryString;
q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
q["sort"] = "id asc,name desc";
var conn = new MockConnection(q);
var mocks = new MockRepository();
var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
var mockR = mocks.DynamicMock<SolrQueryResults<TestDocument>>();
var querySerializer = new SolrQuerySerializerStub(queryString);
With.Mocks(mocks).Expecting(() => {
Expect.Call(parser.Parse(null)).IgnoreArguments().Repeat.Once().Return(mockR);
}).Verify(() => {
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
OrderBy = new[] {
new SortOrder("id", Order.ASC),
new SortOrder("name", Order.DESC)
}
});
});
}
示例12: ResultFields
public void ResultFields()
{
const string queryString = "id:123456";
var q = new Dictionary<string, string>();
q["q"] = queryString;
q["rows"] = SolrQueryExecuter<TestDocument>.ConstDefaultRows.ToString();
q["fl"] = "id,name";
var conn = new MockConnection(q);
var mocks = new MockRepository();
var parser = mocks.StrictMock<ISolrQueryResultParser<TestDocument>>();
var mockR = mocks.DynamicMock<SolrQueryResults<TestDocument>>();
var querySerializer = new SolrQuerySerializerStub(queryString);
With.Mocks(mocks).Expecting(delegate {
Expect.Call(parser.Parse(null)).IgnoreArguments().Repeat.Once().Return(mockR);
}).Verify(() => {
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null);
var r = queryExecuter.Execute(new SolrQuery(queryString), new QueryOptions {
Fields = new[] {"id", "name"},
});
});
}
示例13: FilterQuery
public void FilterQuery()
{
var mocks = new MockRepository();
var parser = mocks.DynamicMock<ISolrQueryResultParser<TestDocument>>();
var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
var conn = new MockConnection(new[] {
KV.Create("q", "*:*"),
KV.Create("rows", "10"),
KV.Create("fq", "id:0"),
KV.Create("fq", "id:2"),
});
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, querySerializer, null, null) {
DefaultRows = 10,
};
queryExecuter.Execute(SolrQuery.All, new QueryOptions {
FilterQueries = new[] {
new SolrQuery("id:0"),
new SolrQuery("id:2"),
},
});
}