我正在尝试这样做:
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
});
我期待像
这样的东西但只能获得
从我的追踪中我看到了
我错过了一件作品,还是走错了路?
答案 0 :(得分:0)
在原始查询中(在顶部),您有q=name_make:[make]+name_model:[model]
,而在name_make:[make] **AND** name_model:[model]
以下,您的默认运营商可能会遇到问题。您可以使用SolrNet使用'+'运算符而不是&amp;&amp;。
.. 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]
不确定是不是这样,但是为了以防万一。
答案 1 :(得分: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;
}