简体   繁体   English

如何在日光浴室中使用分面查询和分面字段?

[英]How to use facet query along with facet field in solarium?

I want alist of cities in facet for a particular list of states in fq.对于 fq 中的特定州列表,我想要 facet 中的城市列表。

So my query is:所以我的查询是:

fq: {!tag=state}state_id:(25 41)

facet query: state_id:(25 41)

facet field: {!ex=state}city_id

This works perfectly fine in Solr Admin, whereas when I query it using Solarium:这在 Solr Admin 中工作得很好,而当我使用 Solarium 查询它时:

    $facetSet->createFacetQuery('city')->setQuery($facet_q);
    $facetSet->createFacetField(array('field'=>'city','exclude'=>'state'));

it gives an empty result.它给出了一个空的结果。

Thanks in advance.提前致谢。

This is pretty old but the same question is relevant also today.这已经很老了,但同样的问题在今天也很重要。

You can do the following with solarium v6:您可以使用 solarium v6 执行以下操作:

$query->createFilterQuery('FilterName')->setQuery('price:340')->addTag('price');

This will be translated to:这将被翻译成:

fq={!tag=price}price:340

Also:还:

$facetSet = $query->getFacetSet();
$facetSet->createFacetField('FacetName')->setField('price')->getLocalParameters()->addExcludes(['price']);

This will be translated to:这将被翻译成:

facet.field={!key=FacetName ex=price}price&facet=true

So as you can see addTag and addExclude should be used.如您所见,应该使用 addTag 和 addExclude。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM