本文整理汇总了C#中SolrQueryExecuter类的典型用法代码示例。如果您正苦于以下问题:C# SolrQueryExecuter类的具体用法?C# SolrQueryExecuter怎么用?C# SolrQueryExecuter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrQueryExecuter类属于命名空间,在下文中一共展示了SolrQueryExecuter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FacetFieldOptions
public void FacetFieldOptions()
{
var querySerializer = new SolrQuerySerializerStub("q");
var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, null);
var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, facetQuerySerializer, null);
var facetOptions = queryExecuter.GetFacetFieldOptions(
new FacetParameters {
Queries = new List<ISolrFacetQuery> {
new SolrFacetQuery(new SolrQuery("q")),
},
Prefix = "pref",
EnumCacheMinDf = 123,
Limit = 100,
MinCount = 5,
Missing = true,
Offset = 55,
Sort = true,
}).ToDictionary(x => x.Key, x => x.Value);
Assert.AreEqual("pref", facetOptions["facet.prefix"]);
Assert.AreEqual("123", facetOptions["facet.enum.cache.minDf"]);
Assert.AreEqual("100", facetOptions["facet.limit"]);
Assert.AreEqual("5", facetOptions["facet.mincount"]);
Assert.AreEqual("true", facetOptions["facet.missing"]);
Assert.AreEqual("55", facetOptions["facet.offset"]);
Assert.AreEqual("true", facetOptions["facet.sort"]);
}
开发者ID:pampero,项目名称:cgFramework,代码行数:26,代码来源:SolrQueryExecuterTests.cs
示例2: ExtraParams
public void ExtraParams()
{
var mocks = new MockRepository();
var parser = mocks.DynamicMock<ISolrQueryResultParser<TestDocument>>();
var conn = mocks.DynamicMock<ISolrConnection>();
var serializer = mocks.StrictMock<ISolrQuerySerializer>();
With.Mocks(mocks)
.Expecting(() => Expect.On(serializer)
.Call(serializer.Serialize(null))
.IgnoreArguments()
.Return("123123"))
.Verify(() => {
var queryExecuter = new SolrQueryExecuter<TestDocument>(parser, conn, serializer, null, null);
var p = queryExecuter.GetAllParameters(new SolrQuery("123123"), new QueryOptions {
ExtraParams = new Dictionary<string, string> {
{"qt", "geo"},
{"lat", "40.75141843299745"},
{"long", "-74.0093994140625"},
{"radius", "1"},
}
}).ToDictionary(x => x.Key, x => x.Value);
Assert.AreEqual("123123", p["q"]);
Assert.AreEqual("geo", p["qt"]);
Assert.AreEqual("1", p["radius"]);
});
}
开发者ID:paulcarroll,项目名称:SolrNet,代码行数:26,代码来源:SolrQueryExecuterTests.cs
示例3: 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);
});
}
开发者ID:paulcarroll,项目名称:SolrNet,代码行数:26,代码来源:SolrQueryExecuterTests.cs
示例4: 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);
}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:14,代码来源:SolrQueryExecuterTests.cs
示例5: 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();
}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:16,代码来源:SolrQueryExecuterTests.cs
示例6: ExtraParams
public void ExtraParams()
{
var querySerializer = new SolrQuerySerializerStub("123123");
var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null);
var p = queryExecuter.GetAllParameters(new SolrQuery("123123"), new QueryOptions {
ExtraParams = new Dictionary<string, string> {
{"qt", "geo"},
{"lat", "40.75141843299745"},
{"long", "-74.0093994140625"},
{"radius", "1"},
}
}).ToDictionary(x => x.Key, x => x.Value);
Assert.AreEqual("123123", p["q"]);
Assert.AreEqual("geo", p["qt"]);
Assert.AreEqual("1", p["radius"]);
}
开发者ID:pampero,项目名称:cgFramework,代码行数:16,代码来源:SolrQueryExecuterTests.cs
示例7: 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);
});
}
开发者ID:7digital,项目名称:SolrNet,代码行数:19,代码来源:SolrQueryTests.cs
示例8: 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" },
});
}
开发者ID:pampero,项目名称:cgFramework,代码行数:17,代码来源:SolrQueryExecuterTests.cs
示例9: SpellChecking
public void SpellChecking()
{
var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, null, null, null);
var p = queryExecuter.GetSpellCheckingParameters(new QueryOptions {
SpellCheck = new SpellCheckingParameters {
Query = "hell",
Build = true,
Collate = true,
Count = 4,
Dictionary = "spanish",
OnlyMorePopular = true,
Reload = true,
},
}).ToList();
Assert.Contains(p, KV.Create("spellcheck", "true"));
Assert.Contains(p, KV.Create("spellcheck.q", "hell"));
Assert.Contains(p, KV.Create("spellcheck.build", "true"));
Assert.Contains(p, KV.Create("spellcheck.collate", "true"));
Assert.Contains(p, KV.Create("spellcheck.count", "4"));
Assert.Contains(p, KV.Create("spellcheck.dictionary", "spanish"));
Assert.Contains(p, KV.Create("spellcheck.onlyMorePopular", "true"));
Assert.Contains(p, KV.Create("spellcheck.reload", "true"));
}
开发者ID:pampero,项目名称:cgFramework,代码行数:23,代码来源:SolrQueryExecuterTests.cs
示例10: MoreLikeThis
public void MoreLikeThis()
{
var querySerializer = new SolrQuerySerializerStub("apache");
var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, querySerializer, null, null);
var p = queryExecuter.GetAllParameters(new SolrQuery("apache"), new QueryOptions {
MoreLikeThis = new MoreLikeThisParameters(new[] { "manu", "cat" }) {
MinDocFreq = 1,
MinTermFreq = 1,
},
}).ToList();
Assert.Contains(p, KV.Create("mlt", "true"));
Assert.Contains(p, KV.Create("mlt.mindf", "1"));
Assert.Contains(p, KV.Create("mlt.fl", "manu,cat"));
Assert.Contains(p, KV.Create("mlt.mintf", "1"));
Assert.Contains(p, KV.Create("q", "apache"));
}
开发者ID:pampero,项目名称:cgFramework,代码行数:16,代码来源:SolrQueryExecuterTests.cs
示例11: 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"),
}
}
});
}
开发者ID:pampero,项目名称:cgFramework,代码行数:24,代码来源:SolrQueryExecuterTests.cs
示例12: NullableDateTime
public void NullableDateTime()
{
var mocks = new MockRepository();
var connection = mocks.CreateMock<ISolrConnection>();
var resultParser = mocks.CreateMock<ISolrQueryResultParser<TestDocWithNullable>>();
var queryExecuter = new SolrQueryExecuter<TestDocWithNullable>(connection, resultParser);
var mapper = new AttributesMappingManager();
var docSerializer = new SolrDocumentSerializer<TestDocWithNullable>(mapper, new DefaultFieldSerializer());
var basicSolr = new SolrBasicServer<TestDocWithNullable>(connection, queryExecuter, docSerializer);
var solr = new SolrServer<TestDocWithNullable>(basicSolr, mapper);
string xml = null;
With.Mocks(mocks)
.Expecting(() => {
Expect.Call(connection.Post(null, null))
.IgnoreArguments()
.Do(new Writer(delegate(string u, string s) {
Console.WriteLine(s);
xml = s;
return null;
}));
})
.Verify(() => {
solr.Add(new TestDocWithNullable());
Assert.AreEqual("<add><doc /></add>", xml);
});
}
开发者ID:osdezwart,项目名称:SolrNet,代码行数:26,代码来源:SolrOperationsTests.cs
示例13: HighlightingWithFastVectorHighlighter
public void HighlightingWithFastVectorHighlighter()
{
var e = new SolrQueryExecuter<TestDocument>(null, null, null, null, null);
var p = e.GetHighlightingParameters(new QueryOptions {
Highlight = new HighlightingParameters {
Fields = new[] {"a"},
AfterTerm = "after",
BeforeTerm = "before",
UseFastVectorHighlighter = true,
}
});
Assert.AreEqual("true", p["hl.useFastVectorHighlighter"]);
Assert.AreEqual("before", p["hl.tag.pre"]);
Assert.AreEqual("after", p["hl.tag.post"]);
Assert.IsFalse(p.ContainsKey("hl.simple.pre"));
Assert.IsFalse(p.ContainsKey("hl.simple.post"));
}
开发者ID:pampero,项目名称:cgFramework,代码行数:17,代码来源:SolrQueryExecuterTests.cs
示例14: NullableDateTime
public void NullableDateTime()
{
var mocks = new MockRepository();
var connection = mocks.StrictMock<ISolrConnection>();
var responseParser = mocks.DynamicMock<ISolrHeaderResponseParser>();
var resultParser = mocks.StrictMock<ISolrQueryResultParser<TestDocWithNullable>>();
var queryExecuter = new SolrQueryExecuter<TestDocWithNullable>(resultParser, connection, null, null);
var mapper = new AttributesMappingManager();
var docSerializer = new SolrDocumentSerializer<TestDocWithNullable>(mapper, new DefaultFieldSerializer());
var validationManager = mocks.StrictMock<IMappingValidator>();
var basicSolr = new SolrBasicServer<TestDocWithNullable>(connection, queryExecuter, docSerializer, null, responseParser, null, null, null);
var solr = new SolrServer<TestDocWithNullable>(basicSolr, mapper, validationManager);
string xml = null;
With.Mocks(mocks)
.Expecting(() => {
Expect.On(connection)
.Call(connection.Post(null, null))
.IgnoreArguments()
.Do(new Writer(delegate(string u, string s) {
Console.WriteLine(s);
xml = s;
return EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml");
}));
})
.Verify(() => {
solr.Add(new TestDocWithNullable());
Assert.AreEqual("<add><doc /></add>", xml);
});
}
开发者ID:Cort01,项目名称:SolrNet,代码行数:29,代码来源:SolrOperationsTests.cs
示例15: TermsSingleField
public void TermsSingleField()
{
var queryExecuter = new SolrQueryExecuter<TestDocument>(null, null, null, null, null);
var p = queryExecuter.GetTermsParameters(new QueryOptions {
Terms = new TermsParameters("text") {
Limit = 10,
Lower = "lower",
LowerInclude = true,
MaxCount = 10,
MinCount = 0,
Prefix = "pre",
Raw = true,
Regex = "regex",
RegexFlag = new[] { RegexFlag.CanonEq, RegexFlag.CaseInsensitive },
Sort = TermsSort.Count,
Upper = "upper",
UpperInclude = true
},
}).ToList();
Assert.Contains(p, KV.Create("terms", "true"));
Assert.Contains(p, KV.Create("terms.fl", "text"));
Assert.Contains(p, KV.Create("terms.lower", "lower"));
Assert.Contains(p, KV.Create("terms.lower.incl", "true"));
Assert.Contains(p, KV.Create("terms.maxcount", "10"));
Assert.Contains(p, KV.Create("terms.mincount", "0"));
Assert.Contains(p, KV.Create("terms.prefix", "pre"));
Assert.Contains(p, KV.Create("terms.raw", "true"));
Assert.Contains(p, KV.Create("terms.regex", "regex"));
Assert.Contains(p, KV.Create("terms.regex.flag", RegexFlag.CanonEq.ToString()));
Assert.Contains(p, KV.Create("terms.regex.flag", RegexFlag.CaseInsensitive.ToString()));
Assert.Contains(p, KV.Create("terms.sort", "count"));
Assert.Contains(p, KV.Create("terms.upper", "upper"));
Assert.Contains(p, KV.Create("terms.upper.incl", "true"));
}
开发者ID:Jroland,项目名称:SolrNet,代码行数:34,代码来源:SolrQueryExecuterTests.cs
示例16: GetAllParameters_mlt_with_field_query
public void GetAllParameters_mlt_with_field_query()
{
var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
var qe = new SolrQueryExecuter<TestDocument>(null, null, serializer, null, null);
var p = qe.GetAllMoreLikeThisHandlerParameters(
new SolrMoreLikeThisHandlerQuery(new SolrQueryByField("id", "1234")),
new MoreLikeThisHandlerQueryOptions(
new MoreLikeThisHandlerParameters(new[] { "one", "three" }) {
MatchInclude = false,
MatchOffset = 5,
ShowTerms = InterestingTerms.None,
}) {
Start = 0,
Rows = 5,
Fields = new[] { "one", "two", "three" },
}).ToList();
Assert.Contains(p, KV.Create("q", "id:(1234)"));
Assert.Contains(p, KV.Create("start", "0"));
Assert.Contains(p, KV.Create("rows", "5"));
Assert.Contains(p, KV.Create("fl", "one,two,three"));
Assert.Contains(p, KV.Create("mlt.fl", "one,three"));
Assert.Contains(p, KV.Create("mlt.match.include", "false"));
Assert.Contains(p, KV.Create("mlt.match.offset", "5"));
Assert.Contains(p, KV.Create("mlt.interestingTerms", "none"));
}
开发者ID:pampero,项目名称:cgFramework,代码行数:25,代码来源:SolrQueryExecuterTests.cs
示例17: FacetFieldQuery
public void FacetFieldQuery()
{
var mocks = new MockRepository();
var query = new Dictionary<string, string>();
query["q"] = "*:*";
query["facet"] = "true";
query["facet.field"] = "cat";
query["rows"] = "0";
var connection = new MockConnection(query);
var resultParser = mocks.StrictMock<ISolrQueryResultParser<TestDocumentWithUniqueKey>>();
var mapper = mocks.StrictMock<IReadOnlyMappingManager>();
var validationManager = mocks.StrictMock<IMappingValidator>();
var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>();
With.Mocks(mocks).Expecting(() => {
Expect.On(resultParser)
.Call(resultParser.Parse(""))
.IgnoreArguments()
.Repeat.Once()
.Return(new SolrQueryResults<TestDocumentWithUniqueKey> {
FacetFields = new Dictionary<string, ICollection<KeyValuePair<string, int>>> {
{
"cat", new List<KeyValuePair<string, int>> {
new KeyValuePair<string, int>("electronics", 5),
new KeyValuePair<string, int>("hard drive", 3),
}
}
}
});
}).Verify(() => {
var querySerializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
var facetQuerySerializer = new DefaultFacetQuerySerializer(querySerializer, new DefaultFieldSerializer());
var queryExecuter = new SolrQueryExecuter<TestDocumentWithUniqueKey>(resultParser, connection, querySerializer, facetQuerySerializer);
var basicSolr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, queryExecuter, docSerializer, null, null, null, null, null);
var solr = new SolrServer<TestDocumentWithUniqueKey>(basicSolr, mapper, validationManager);
var r = solr.FacetFieldQuery(new SolrFacetFieldQuery("cat"));
Assert.AreEqual(2, r.Count);
Assert.AreEqual("electronics", r.First().Key);
});
}
开发者ID:Cort01,项目名称:SolrNet,代码行数:39,代码来源:SolrOperationsTests.cs
示例18: 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"),
},
});
}
开发者ID:pampero,项目名称:cgFramework,代码行数:22,代码来源:SolrQueryExecuterTests.cs
示例19: 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]")),
}
}
});
}
开发者ID:pampero,项目名称:cgFramework,代码行数:24,代码来源:SolrQueryExecuterTests.cs
示例20: QueryWithPagination
public void QueryWithPagination()
{
const string qstring = "id:123";
const int start = 10;
const int rows = 20;
var mocks = new MockRepository();
//var connection = mocks.CreateMock<ISolrConnection>();
var query = new Dictionary<string, string>();
query["q"] = qstring;
query["start"] = start.ToString();
query["rows"] = rows.ToString();
var connection = new MockConnection(query);
var parser = mocks.CreateMock<ISolrQueryResultParser<TestDocumentWithUniqueKey>>();
var docSerializer = mocks.CreateMock<ISolrDocumentSerializer<TestDocumentWithUniqueKey>>();
With.Mocks(mocks).Expecting(() => {
Expect.On(parser).Call(parser.Parse(null))
.IgnoreArguments()
.Return(new SolrQueryResults<TestDocumentWithUniqueKey>());
}).Verify(() => {
var executer = new SolrQueryExecuter<TestDocumentWithUniqueKey>(connection, parser);
var solr = new SolrBasicServer<TestDocumentWithUniqueKey>(connection, executer, docSerializer);
var r = solr.Query(new SolrQuery(qstring), new QueryOptions {Start = start, Rows = rows});
});
}
开发者ID:osdezwart,项目名称:SolrNet,代码行数:25,代码来源:SolrOperationsTests.cs
注:本文中的SolrQueryExecuter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论