本文整理汇总了C#中SolrQueryExecuter类的典型用法代码示例。如果您正苦于以下问题:C# SolrQueryExecuter类的具体用法?C# SolrQueryExecuter怎么用?C# SolrQueryExecuter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrQueryExecuter类属于命名空间,在下文中一共展示了SolrQueryExecuter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"]);
}
示例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"]);
});
}
示例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);
});
}
示例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);
}
示例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();
}
示例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"]);
}
示例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);
});
}
示例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" },
});
}
示例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"));
}
示例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"));
}
示例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"),
}
}
});
}
示例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);
});
}
示例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"));
}
示例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);
});
}
示例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"));
}