facet on two multi-valued fields

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

facet on two multi-valued fields

ahubold
Hi,

my schema looks like this

<field name="id" type="string" .../>
<field name="tagIds" type="string" indexed="true" stored="true"
multiValued="true"/>
<field name="tagDescriptions" type="text_general" indexed="true"
stored="false" multiValued="true"/>
<field name="text" type="text_general" .../>

I'd like to get the tagIds of documents with a certain tagDescription
(and text). However tagIds contains multiple ids in the same order as
tagDescription and simple faceting would return all. Is there a way to
just get the IDs of the tags with a matching description?

Or would you recommend some other schema?

Thanks,
Andreas


Reply | Threaded
Open this post in threaded view
|

Re: facet on two multi-valued fields

Jan Høydahl / Cominvent
It makes no sense to facet on a “text_general” ananlyzed field. Can you give a concrete example with a few dummy docs and show some queries (do you query the tagDescription field?) and wanted facet output?

There may be several ways to solve the task, depending on the exact use case. One solution could be to use child documents.

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

> 2. mar. 2016 kl. 17.30 skrev Andreas Hubold <[hidden email]>:
>
> Hi,
>
> my schema looks like this
>
> <field name="id" type="string" .../>
> <field name="tagIds" type="string" indexed="true" stored="true" multiValued="true"/>
> <field name="tagDescriptions" type="text_general" indexed="true" stored="false" multiValued="true"/>
> <field name="text" type="text_general" .../>
>
> I'd like to get the tagIds of documents with a certain tagDescription (and text). However tagIds contains multiple ids in the same order as tagDescription and simple faceting would return all. Is there a way to just get the IDs of the tags with a matching description?
>
> Or would you recommend some other schema?
>
> Thanks,
> Andreas
>
>

Reply | Threaded
Open this post in threaded view
|

Re: facet on two multi-valued fields

ahubold
Hi,

sorry, the subject may have been misleading. I want to get facet results
for only one field (tagIds) but restrict the returned values to those
with a matching tagDescription. Both multi-valued fields have the same
order.

Example docs

id:"1"
tagIds:["10","12","13"]
tagDescriptions:["News", "Sport News", "Economy"]
text:"... foo ..."

id:"2"
tagIds:["14", "10"]
tagDescriptions:["IT", "News"]
text:"... foo ..."

Query
q=text:foo
&fq=tagDescriptions:news
&facet.field=tagIds

IIRC, this would give me a facet result with values 10, 12, 13, 14 but I
want to restrict the result to 10, 12 (the ones with "News" in their
tagDescription)

I thought about using query-time join but am unsure about performance
implications (if there are many tags) and concrete usage.

Or is it possible to somehow put both tagIds and tagDescriptions into a
single multi-valued field?

Thank you,
Andreas


Jan Høydahl schrieb am 02.03.2016 um 22:52:

> It makes no sense to facet on a “text_general” ananlyzed field. Can you give a concrete example with a few dummy docs and show some queries (do you query the tagDescription field?) and wanted facet output?
>
> There may be several ways to solve the task, depending on the exact use case. One solution could be to use child documents.
>
> --
> Jan Høydahl, search solution architect
> Cominvent AS - www.cominvent.com
>
>> 2. mar. 2016 kl. 17.30 skrev Andreas Hubold <[hidden email]>:
>>
>> Hi,
>>
>> my schema looks like this
>>
>> <field name="id" type="string" .../>
>> <field name="tagIds" type="string" indexed="true" stored="true" multiValued="true"/>
>> <field name="tagDescriptions" type="text_general" indexed="true" stored="false" multiValued="true"/>
>> <field name="text" type="text_general" .../>
>>
>> I'd like to get the tagIds of documents with a certain tagDescription (and text). However tagIds contains multiple ids in the same order as tagDescription and simple faceting would return all. Is there a way to just get the IDs of the tags with a matching description?
>>
>> Or would you recommend some other schema?
>>
>> Thanks,
>> Andreas
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: facet on two multi-valued fields

Jan Høydahl / Cominvent
Hi,

BlockJoin with Parent/Child is your solution.
See http://yonik.com/solr-nested-objects/ and https://cwiki.apache.org/confluence/display/solr/BlockJoin+Faceting

--
Jan Høydahl, search solution architect
Cominvent AS - www.cominvent.com

> 3. mar. 2016 kl. 10.35 skrev Andreas Hubold <[hidden email]>:
>
> Hi,
>
> sorry, the subject may have been misleading. I want to get facet results for only one field (tagIds) but restrict the returned values to those with a matching tagDescription. Both multi-valued fields have the same order.
>
> Example docs
>
> id:"1"
> tagIds:["10","12","13"]
> tagDescriptions:["News", "Sport News", "Economy"]
> text:"... foo ..."
>
> id:"2"
> tagIds:["14", "10"]
> tagDescriptions:["IT", "News"]
> text:"... foo ..."
>
> Query
> q=text:foo
> &fq=tagDescriptions:news
> &facet.field=tagIds
>
> IIRC, this would give me a facet result with values 10, 12, 13, 14 but I want to restrict the result to 10, 12 (the ones with "News" in their tagDescription)
>
> I thought about using query-time join but am unsure about performance implications (if there are many tags) and concrete usage.
>
> Or is it possible to somehow put both tagIds and tagDescriptions into a single multi-valued field?
>
> Thank you,
> Andreas
>
>
> Jan Høydahl schrieb am 02.03.2016 um 22:52:
>> It makes no sense to facet on a “text_general” ananlyzed field. Can you give a concrete example with a few dummy docs and show some queries (do you query the tagDescription field?) and wanted facet output?
>>
>> There may be several ways to solve the task, depending on the exact use case. One solution could be to use child documents.
>>
>> --
>> Jan Høydahl, search solution architect
>> Cominvent AS - www.cominvent.com
>>
>>> 2. mar. 2016 kl. 17.30 skrev Andreas Hubold <[hidden email]>:
>>>
>>> Hi,
>>>
>>> my schema looks like this
>>>
>>> <field name="id" type="string" .../>
>>> <field name="tagIds" type="string" indexed="true" stored="true" multiValued="true"/>
>>> <field name="tagDescriptions" type="text_general" indexed="true" stored="false" multiValued="true"/>
>>> <field name="text" type="text_general" .../>
>>>
>>> I'd like to get the tagIds of documents with a certain tagDescription (and text). However tagIds contains multiple ids in the same order as tagDescription and simple faceting would return all. Is there a way to just get the IDs of the tags with a matching description?
>>>
>>> Or would you recommend some other schema?
>>>
>>> Thanks,
>>> Andreas
>>>
>>>
>>
>