Solr and facet search

后端 未结 5 1261
迷失自我
迷失自我 2021-02-03 10:08

Does facet searching come built in when you setup your schema or do you have to do some things to set this up?

Does it basically work out of the box on all the fields th

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 10:56

    The below code in C#, by using SolrNet package. The Facet you can do it on the fields stored in SOLR, make sure its string and doesn't have space for better results. The mincount is for limiting the minimum number to get listed in facet.

            QueryOptions options = new QueryOptions
            {                
                Facet = new FacetParameters
                {
                    Queries = new ISolrFacetQuery[]
                    {
                        new SolrFacetFieldQuery("field1"),
                        new SolrFacetFieldQuery("field2")
                    },
                    MinCount = 20
                }
            };
    

    And the below code to get the results, query - is the search entered in front end.

        var result = solr.Query(query, options);
    

提交回复
热议问题