Limiting / Filtering multivalue fields in Solr

久未见 提交于 2019-12-24 01:52:59

问题


Is there a way to limit, or filter, the returned text of a multivalued field in Solr? Given the following document structure in Solr:

...
<doc>
    <str name="title">example</str>
    <arr name="foo">
        <str>bar1</str>
        <str>bar2</str>
        <str>bar3</str>
        <str>bar4</str>
        <str>bar5</str>
        <str>bar6</str>
    </arr>
</doc>
...

I'd like to limit the response to only show 1 of the "foo" values based on a Filter Query request. So for example, the query:

select/?q=example&fq=foo:bar2`

I would want a response of:

...
<doc>
    <str name="title">example</str>
    <arr name="foo">
        <str>bar2</str>
    </arr>
</doc>
...

回答1:


Nope. There is not way to filter the Multivalued Values returned with the response.
You can easily do it at client side though.

If you can use Facet to get the list, you can use facet.prefix to limit the values for the field foo returned as facet.




回答2:


Did you try using dynamic fields if you know the sample space of values for 'foo'? For example:

and then filter on bar_x:true. You would end up using a large number of dynamic fields.




回答3:


filter query should work, try below code

&fq=+foo:"bar2"



来源:https://stackoverflow.com/questions/14015696/limiting-filtering-multivalue-fields-in-solr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!