当前位置: 首页>>代码示例>>C#>>正文


C# SolrQuery类代码示例

本文整理汇总了C#中SolrQuery的典型用法代码示例。如果您正苦于以下问题:C# SolrQuery类的具体用法?C# SolrQuery怎么用?C# SolrQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SolrQuery类属于命名空间,在下文中一共展示了SolrQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Concat_different_types

 public void Concat_different_types() {
     var q1 = new SolrQuery("1");
     var q2 = new SolrQueryByField("f", "v");
     var qm = new SolrMultipleCriteriaQuery(new ISolrQuery[] {q1, q2});
     Console.WriteLine(Serialize(qm));
     Assert.AreEqual("(1  f:(v))", Serialize(qm));
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:7,代码来源:SolrMultipleCriteriaQueryTests.cs

示例2: AcceptsNulls

 public void AcceptsNulls()
 {
     var q1 = new SolrQuery("1");
     ISolrQuery q2 = null;
     var qm = new SolrMultipleCriteriaQuery(new[] {q1, q2});
     Assert.AreEqual("(1)", Serialize(qm));
 }
开发者ID:Cort01,项目名称:SolrNet,代码行数:7,代码来源:SolrMultipleCriteriaQueryTests.cs

示例3: Facet1Async

 public async Task Facet1Async()
 {
     var termsFacetFor = new SolrQuery<TechProduct>().SearchFor("*", "lucene").Take(0).TermsFacetFor(x => x.Category);
     termsFacetFor = termsFacetFor.RangeFacetFor(x => x.Popularity, x => x.Range(5, 10, "1"));
     termsFacetFor = termsFacetFor.RangeFacetFor(x => x.ManufactureDate,
         x =>
             x.Range(DateTime.Now.AddYears(-20), DateTime.Now, "+1YEAR")
                 .TermsFacetFor(y => y.Category,
                     y => y.RangeFacetFor(z => z.Popularity, z => z.Range(5, 10, "1"))));
     var searchResult = await _repository.SearchAsync(termsFacetFor);
     var bucket = searchResult.Raw.Facets["R2"]["buckets"].ToList()[10]["T0"]["buckets"].ToList()[0]["R0"]["buckets"].ToList()[1];
     Assert.AreEqual(6, bucket["val"]);
     Assert.AreEqual(2, bucket["count"]);
     //var facetC = new SolrQueryStatisticsFacet<TechProduct>("unique(cat)");
     //var facetA = new SolrQueryTermsFacet<TechProduct>(x => x.Category).Facet("D", facetC);
     //var facetB = new SolrQueryTermsFacet<TechProduct>(x => x.LastModified).Facet("D", facetC);
     //var query = new SolrQuery<TechProduct>().Take(0).Facet("A", facetA).Facet("B", facetB).Facet("C", facetC);
     //var r3 = await _repository.Get(query);
     //Assert.AreEqual(0, r3.Response.Documents.Count());
     //var facets = r3.GetFacets();
     //Assert.AreEqual(37, (long)r3.Facets["count"]);
     //var facetObject = (JObject)r3.Facets["A"];
     //var dic = facetObject.ToObject<IDictionary>();
     //Assert.AreNotEqual(null, dic);
 }
开发者ID:Qobra,项目名称:Solr.Net,代码行数:25,代码来源:IntegrationTest.cs

示例4: Concat

 public void Concat()
 {
     var q1 = new SolrQuery("1");
     var q2 = new SolrQuery("2");
     var qm = new SolrMultipleCriteriaQuery(new[] {q1, q2});
     Assert.AreEqual("(1  2)", Serialize(qm));
 }
开发者ID:Cort01,项目名称:SolrNet,代码行数:7,代码来源:SolrMultipleCriteriaQueryTests.cs

示例5: SolrQuery_Boost

 public void SolrQuery_Boost()
 {
     var q = new SolrQuery("solr").Boost(12.2);
     var serializer = new DefaultQuerySerializer(new DefaultFieldSerializer());
     var query = serializer.Serialize(q);
     Assert.AreEqual("(solr)^12.2", query);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:7,代码来源:SolrQueryBoostTests.cs

示例6: PlusEqualMany

 public void PlusEqualMany() {
     AbstractSolrQuery q = new SolrQuery("first");
     foreach (var _ in Enumerable.Range(0, 10)) {
         q += new SolrQuery("others");
     }
     Assert.AreEqual("((((((((((first  others)  others)  others)  others)  others)  others)  others)  others)  others)  others)", Serialize(q));
 }
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:7,代码来源:OperatorOverloadingTests.cs

示例7: Users

        public IPagedResult<IResult> Users(string name, uint pageIndex = 0, uint pageSize = 10)
        {
            var q = new SolrQuery
                {
                    Query = string.Format("(Name:{0}*)(Name_split:{0}*)", name.ToLower().Replace(" ", "\\ ")),
                    PageIndex = pageIndex,
                    PageSize = pageSize
                };
            var results = ViewManager.GetView("UserSearch").Query(q);

            return results;
        }
开发者ID:CHAOS-Community,项目名称:Portal.Module.Larmfm,代码行数:12,代码来源:Search.cs

示例8: Facet

        public QueryResult Facet(string query, string facetField)
        {
            var q = new SolrQuery
                {
                    Query = query,
                    Facet = string.Format("field:{0}", facetField)
                };
            
            var result = ViewManager.GetView("Search").FacetedQuery(q);
            var fieldFacets = result.FacetFieldsResult.Select(item => new FieldFacet(item.Value, item.Facets.Select(facet => new Facet(facet.Value, facet.Count)).ToList()));

            return new QueryResult { FieldFacets = fieldFacets.ToList() };
        }
开发者ID:CHAOS-Community,项目名称:Portal.Module.Larmfm,代码行数:13,代码来源:Search.cs

示例9: Get_WithObjectTypeQuery_ShouldQueryViewWithObjectTypeIdAndFolders

        public void Get_WithObjectTypeQuery_ShouldQueryViewWithObjectTypeIdAndFolders()
        {
            var extension  = Make_ObjectV5Extension();
            var folder     = new Folder{ID = 1};
            var user       = Make_User();
            var query      = new SolrQuery {Query = "ObjectTypeID:1"};
            PortalApplication.Setup(m => m.Log.Debug(It.IsAny<string>(), null)); 
            ViewManager.Setup(m => m.GetView("Object").Query(It.Is<IQuery>(q => q.Query == "(ObjectTypeId:1)AND((FolderAncestors:1))"))).Returns(new PagedResult<IResult>(0, 0, new IResult[0]));
            PortalRequest.SetupGet(p => p.User).Returns(user);
            PermissionManager.Setup(m => m.GetFolders(FolderPermission.Read, user.Guid, It.IsAny<IEnumerable<Guid>>())).Returns(new[] { folder });

            extension.Get(query, null, true, true, true, true);

            ViewManager.Verify(m => m.GetView("Object").Query(It.Is<IQuery>(q => q.Query == "(ObjectTypeId:1)AND((FolderAncestors:1))")));
        }
开发者ID:CHAOS-Community,项目名称:CHAOS.Portal.MCM,代码行数:15,代码来源:ObjectTest.cs

示例10: DeleteByQuery

		public void DeleteByQuery() {
            const string queryString = "someQuery";
		    var q = new SolrQuery(queryString);
            var xml = string.Format("<delete><query>{0}</query></delete>", queryString);

		    var conn = new Mocks.MSolrConnection();
		    conn.post = conn.post.Args("/update", xml);

		    var querySerializer = new Mocks.MSolrQuerySerializer();
		    querySerializer.serialize += _ => queryString;

            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(null, q, querySerializer), null);
            cmd.Execute(conn);

            Assert.AreEqual(1, conn.post.Calls);
		}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:16,代码来源:DeleteCommandTests.cs

示例11: DeleteByIdAndQuery

        public void DeleteByIdAndQuery()
        {
            var ids = new[] { "123", "456" };
            const string queryString = "someQuery";
            var xml = string.Format("<delete><id>{0}</id><id>{1}</id><query>{2}</query></delete>", ids[0], ids[1], queryString);
            var conn = new Mocks.MSolrConnection();
            conn.post = conn.post.Args("/update", xml);

            var q = new SolrQuery(queryString);
            var querySerializer = new Mocks.MSolrQuerySerializer();
            querySerializer.serialize += _ => queryString;

            var cmd = new DeleteCommand(new DeleteByIdAndOrQueryParam(ids, q, querySerializer));
            cmd.Execute(conn);

            Assert.AreEqual(1, conn.post.Calls);
        }
开发者ID:richtea,项目名称:SolrNet,代码行数:17,代码来源:DeleteCommandTests.cs

示例12: Get

        public IPagedResult<IResult> Get(IEnumerable<Guid> objectGuids, uint? folderId = null, Guid? accessPointGuid = null, bool includeAccessPoints = false, bool includeMetadata = false, bool includeFiles = false, bool includeObjectRelations = false, bool includeFolders = false, uint pageSize = 10, uint pageIndex = 0)
        {
            var query = new SolrQuery
                {
                    Query = "*:*", 
                    PageIndex = pageIndex, 
                    PageSize = pageSize
                };

            if (objectGuids.Any()) query.Query = string.Format("Id:{0}", string.Join(" ", objectGuids));

            var folderFilter = GetFoldersWithAccess(folderId);

            if(accessPointGuid == null && !folderFilter.Any()) throw new InsufficientPermissionsException("No folders with access");

            return ObjectQueryHelper.GetObjects(query, accessPointGuid, folderFilter,
                                                                       includeAccessPoints, includeMetadata,
                                                                       includeFiles, includeObjectRelations,
                                                                       includeFolders);
        }
开发者ID:CHAOS-Community,项目名称:CHAOS.Portal.MCM,代码行数:20,代码来源:Object.cs

示例13: Minus

 public void Minus()
 {
     var q = new SolrQuery("solr") - new SolrQuery("name:desc");
     Assert.AreEqual("(solr  -name:desc)", Serialize(q));
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:5,代码来源:OperatorOverloadingTests.cs

示例14: AndNot

 public void AndNot()
 {
     var q = new SolrQuery("a") && !new SolrQuery("b");
     Console.WriteLine(Serialize(q));
     Assert.AreEqual("(a AND -b)", Serialize(q));
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:6,代码来源:OperatorOverloadingTests.cs

示例15: Add

 public void Add()
 {
     var q = new SolrQuery("solr") + new SolrQuery("name:desc");
     Assert.AreEqual("(solr  name:desc)", Serialize(q));
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:5,代码来源:OperatorOverloadingTests.cs


注:本文中的SolrQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。