2

我正在尝试这样做:

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:[make] AND name_model:[model] AND price:[0 TO 250000] AND year_registration:[0 TO 10000000]) 0,023619 0,000006
  • Solr fq {!tag=dt mincount=1}name_model:A3

我错过了一块,还是走错了路?

4

2 回答 2

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]

不知道是不是这样,但为了以防万一,可以尝试一下。

于 2012-12-08T16:15:10.027 回答
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;
    }
于 2017-10-11T14:15:59.487 回答