2012-12-06 66 views
2

我試圖做到這一點:查詢Solr的(Solr.net)多條件查詢和localparams

http://solr:8080/solr/select/?q=name_make:[make]+name_model:[model]&rows=10000&wt=json&fq={!tag=dt}name_model:[model]&facet=on&facet.field={!ex=dt}name_model&facet.sort=count&facet.field.mincount=1 

隨着solr.net - 我有這樣的:

var multipleQuery = new SolrMultipleCriteriaQuery(queryList, "AND"); 
var Facets = new FacetParameters(); 

Facets.Queries.Add(new SolrFacetFieldQuery(new LocalParams{{"ex", "dt"}} +"name_model") { MinCount = 1, Sort = true}); 

List<ISolrQuery> filter = new List<ISolrQuery>(); 
filter.Add(new LocalParams { { "tag", "dt" }, { "mincount", "1" } } + Query.Field("name_model").Is(NameModel)); 

var result = solr.Query(multipleQuery, new QueryOptions 
                { 
                 FilterQueries = filter, 
                 Rows = rows, 
                 Facet = facets, 
                 Start = index 
                }); 

我想到的東西像

  • 化妝1 [] 101
  • 使2 [] 144
  • 使3 [X] 232
  • 使2] 32

但只得到

  • 使3 [X] 232

從我跟蹤我看到

  • Solr的q(name_make:使] AND name_model:[模型] AND價:[0 TO 250000] AND year_registration:0〜10000000])0,023619 0,000006
  • Solr的FQ name_model {標籤= DT mincount = 1!}:A3

我失去了一塊,還是繞了錯誤的方式?

回答

0

在原來的查詢中(頂部),你有q=name_make:[make]+name_model:[model],下面你有name_make:[make] **AND** name_model:[model],所以它可能是你的默認操作符的問題。您可以保留此使用SolrNet使用「+」操作符代替& &。

... new SolrQuery("name_make:[make]") + new SolrQuery("name_model:[model]")

..將返回:name_make:[make] name_model:[model]

凡爲..

new SolrQuery("name_make:[make]") && new SolrQuery("name_model:[model]")

..將返回:name_make:[make] AND name_model:[model]

不知道這是它,但一些嘗試,以防萬一。

0
Please try to pass the string arraty that contains multiple field names and search text in the below method. I will return the solrnet query for search with multiple filed name with OR condition. 

public ISolrQuery BuildQuery(string[] SearchFields, string SearchText) 
    { 

     AbstractSolrQuery firstQuery = new SolrQueryByField(parameters.SearchFields[0], SearchText) { Quoted = false }; 
     for (var i = 1; i < SearchFields.Length; i++) 
     { 
      firstQuery = firstQuery || new SolrQueryByField(SearchFields[i], SearchText) { Quoted = false }; 
     } 

     return firstQuery; 
    }