本文整理汇总了C#中SolrBasicServer.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# SolrBasicServer.AsQueryable方法的具体用法?C# SolrBasicServer.AsQueryable怎么用?C# SolrBasicServer.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolrBasicServer
的用法示例。
在下文中一共展示了SolrBasicServer.AsQueryable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collection
public void Collection()
{
var conn = new MockConnection(new Dictionary<string, string> {
{"fq", "id:0"},
{"q", "*:*"},
{"rows", "100000000"},
});
var mocks = new MockRepository();
var queryExec = mocks.StrictMock<ISolrQueryExecuter<Document>>();
var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<Document>>();
ISolrBasicReadOnlyOperations<Document> solr = new SolrBasicServer<Document>(conn, queryExec, docSerializer, null, null, null, null, null);
var linqQuery = from doc in solr.AsQueryable()
where doc.Categories.AnyItem() == "cat1"
select doc;
QueryOptions qo;
var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);
Assert.AreEqual("(cat:cat1)", resDocs.Query);
}
示例2: Boosting
public void Boosting()
{
var conn = new MockConnection(new Dictionary<string, string> {
{"fq", "id:0"},
{"q", "*:*"},
{"rows", "100000000"},
});
var mocks = new MockRepository();
var queryExec = mocks.StrictMock<ISolrQueryExecuter<Document>>();
var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<Document>>();
ISolrBasicReadOnlyOperations<Document> solr = new SolrBasicServer<Document>(conn, queryExec, docSerializer, null, null, null, null, null);
var linqQuery = from doc in solr.AsQueryable()
where (doc.Name == "john").Boost(10)
select doc;
QueryOptions qo;
var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);
Assert.AreEqual("(name:john)^10", resDocs.Query);
}
示例3: AndsOrs
public void AndsOrs()
{
var conn = new MockConnection(new Dictionary<string, string> {
{"fq", "id:0"},
{"q", "*:*"},
{"rows", "100000000"},
});
var mocks = new MockRepository();
var queryExec = mocks.StrictMock<ISolrQueryExecuter<Document>>();
var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<Document>>();
ISolrBasicReadOnlyOperations<Document> solr = new SolrBasicServer<Document>(conn, queryExec, docSerializer, null, null, null, null, null);
var linqQuery = from doc in solr.AsQueryable()
where doc.DefaultFieldEquals("aa") && (doc.Price >= 1 || doc.Price <= 11)
select doc;
QueryOptions qo;
var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);
Assert.AreEqual("(aa AND ((price:[1 TO *]) OR (price:[* TO 11])))", resDocs.Query);
}
示例4: Sort
public void Sort()
{
var conn = new MockConnection(new Dictionary<string, string> {
{"fq", "id:0"},
{"q", "*:*"},
{"rows", "100000000"},
});
var mocks = new MockRepository();
var queryExec = mocks.StrictMock<ISolrQueryExecuter<Document>>();
var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<Document>>();
ISolrBasicReadOnlyOperations<Document> solr = new SolrBasicServer<Document>(conn, queryExec, docSerializer, null, null, null, null, null);
int priceVal = 1;
DateTime dt = new DateTime(2011, 1, 1);
var linqQuery = from doc in solr.AsQueryable()
where (doc.Price >= priceVal || doc.Timestamp >= dt)
orderby doc.Id, doc.Price descending
select doc;
QueryOptions qo;
var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);
Assert.AreEqual(qo.OrderBy.Count, 2);
var so = new SortOrder("id", Order.ASC);
Assert.IsTrue(qo.OrderBy.Contains(so));
so = new SortOrder("price", Order.DESC);
Assert.IsTrue(qo.OrderBy.Contains(so));
}
示例5: PartialEval
public void PartialEval()
{
var conn = new MockConnection(new Dictionary<string, string> {
{"fq", "id:0"},
{"q", "*:*"},
{"rows", "100000000"},
});
var mocks = new MockRepository();
var queryExec = mocks.StrictMock<ISolrQueryExecuter<Document>>();
var docSerializer = mocks.StrictMock<ISolrDocumentSerializer<Document>>();
ISolrBasicReadOnlyOperations<Document> solr = new SolrBasicServer<Document>(conn, queryExec, docSerializer, null, null, null, null, null);
int priceVal = 1;
DateTime dt = new DateTime(2011, 1, 1);
var linqQuery = from doc in solr.AsQueryable()
where (doc.Price >= priceVal || doc.Timestamp >= dt)
select doc;
QueryOptions qo;
var resDocs = ((IQueryableSolrNet<Document>)linqQuery).GetSolrQuery(out qo);
Assert.AreEqual("((price:[1 TO *]) OR (timestamp:[2011-01-01T12:00:00.000Z TO *]))", resDocs.Query);
}