我使用的是Spring Data Solr 4.0.5.RELEASE,找不到在我的过滤器查询中正确标记字段以实现{!tag=price}price:10
之类的方法。这里有一个类似的帖子,并且是一个可接受的答案https://stackoverflow.com/a/16903861/10225026,但是当我使用像Criteria.where("{!tag=price}price").isNull()
这样的isNull()标准时,此解决方案将不起作用。查询最终是-{!tag=price}price:[* TO *]
而不是{!tag=price}-price:[* TO *]
。
出于相同的原因,在带有标签/键/排除的字段上无法将FieldWithFacetParameters与setMissing(true)
之类的参数一起使用,因为弹簧数据在应为f.{!key=price ex=typeId,modelId,status}price.facet.missing=true
时会产生类似f.price.facet.missing=true
的查询。
是否有正确的方法来向查询字段添加标签/键和排除项?
我使用以下内容为过滤器查询添加查询标记:
SimpleQuery query = new SimpleFacetQuery();
....
query.addFilterQuery(new SimpleQuery(new Criteria("{!tag=price}-price").isNull()));
并且对于方面选项:
SimpleFacetQuery query = new SimpleFacetQuery();
...
FacetOptions facetOptions = new FacetOptions();
facetOptions.addFacetOnField("{!key=price ex=typeId,modelId,status}price");
query.setFacetOptions(facetOptions);
要使构面选项起作用,还需要将以下内容添加到solrconfig.xml中的请求处理程序默认参数中:
<requestHandler name="/select" class="solr.SearchHandler">
....
<lst name="appends">
<str name="f.price.facet.missing">true</str>
</lst>
....