You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Bill Bell <bi...@gmail.com> on 2011/06/22 03:47:29 UTC

MultiValued facet behavior question

I have a field: specialties that is multiValued.

It indicates the doctor's specialties: cardiologist, internist, etc.

When someone does a search: "Cardiologist", I use
q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=specialt
ies

What I want to come out in the facet is the Cardiologist (since it matches
exactly) and the number that matches: 700.
I don't want to see the other values that are not Cardiologist.

Now I see:

Cardiologist: 700
Internist: 45
Family Doctor: 20

This means that several Cardiologist's are also internists and family
doctors. When it matches exactly, I don't want to see Internists, Family
Doctors. How do I send a query to Solr with a condition.
Facet.query=specialties:Cardiologist&facet.field=specialties

Then if the query returns something use it, otherwise use the field one?

Other ideas?




Re: MultiValued facet behavior question

Posted by Darren Govoni <da...@ontrenet.com>.
How is that different from doing a field search and just counting the 
results?
If you only want the facet of the searched term (input), then why not just
combine that with the result count and use that?

Facets are more useful when you _don't_ know the distribution of values
across a result set because they weren't included in the search criteria.

Maybe this needs a new name or handler than facet.

What am I missing?

On 06/22/2011 03:44 AM, Bill Bell wrote:
> Here is an example using exampledocs and trunk 4.0:
>
> http://localhost:8983/solr/select/?q=cat:%22hard%20drive%22&version=2.2&sta
> rt=0&rows=10&indent=on&facet=true&facet.field=cat&facet.query={!lucene}cat:
> %22hard%20drive%22&facet.mincount=1
>
> Results:
>
> <result name="response" numFound="2" start="0">
> Etc....
> <lst name="facet_queries">
> <int name="{!lucene}cat:"hard drive"">2</int>
> </lst>
> <lst name="facet_fields">
> <lst name="cat">
>      <int name="electronics">2</int>
>      <int name="hard drive">2</int>
> </lst></lst>
>
> Notice that the facet_queries count "2" is the same as the the numFound=2.
>
> But I have no way to use facet.field to count the matches.
>
> The algorithm -
>
> Loop through multiValued field and match on "hard drive". Ignore other
> values in there when setting the facet list....
>
>
>
>
> On 6/22/11 1:19 AM, "Dennis de Boer"<da...@gmail.com>  wrote:
>
>> Hi Bill,
>>
>> yes, you absolutely do make sense. I posted the exact same question to
>> this
>> mailing list (subject: faceting on multivalued fields), but got no
>> response
>> out of it. A friend of mine is now helping out.
>>
>> I hope someone on the list can give us some advice. I'll post our findings
>> to this topic.
>>
>> Regards,
>> Dennis
>>
>>
>> On Wed, Jun 22, 2011 at 5:37 AM, Bill Bell<bi...@gmail.com>  wrote:
>>
>>> Doing it with q=specialities:Cardiologist or
>>> q=Cardiologist&defType=dismax&qf=specialties
>>> does not matter, the issue is how I see facets. I want the facets to
>>> only
>>> show the one match,
>>> and not all the multiValued fields in specialties that match...
>>>
>>> Example,
>>>
>>> Name|specialties
>>> Bell|Cardiologist
>>> Smith|Cardiologist,Family Doctor
>>> Adams,Cardiologist,Family Doctor,Internist
>>>
>>> When I facet.field=specialties I get:
>>>
>>> Cardiologist: 3
>>> Internist: 1
>>> Family Doctor: 1
>>>
>>>
>>> I only want it to return:
>>>
>>> Cardiologist: 3
>>>
>>> Because this matches exactly... Facet on the field that matches and only
>>> return the number for that.
>>>
>>> It can get more complicated. Here is another example:
>>>
>>> q=cardiology&defType=dismax&qf=specialties
>>>
>>>
>>> (Cardiology and cardiologist are stems)...
>>>
>>> But I don't really know which value in Cardiologist match perfectly.
>>>
>>> Again, I only want it to return:
>>>
>>> Cardiologist: 3
>>>
>>> If I searched on q=internist&defType=dismax&qf=specialties, I want the
>>> result to be:
>>>
>>>
>>> Internist: 1
>>>
>>>
>>> Does this all make sense?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 6/21/11 8:23 PM, "Darren Govoni"<da...@ontrenet.com>  wrote:
>>>
>>>> So are you saying that for all results for "cardiologist",
>>>> you don't want facets not matching "Cardiologist" to be
>>>> returned as facets?
>>>>
>>>> what happens when you make q=specialities:Cardiologist?
>>>> instead of just q=Cardiologist?
>>>>
>>>> Seems that if you make the query on the field, then all
>>>> your results will necessarily qualify and you can discard
>>>> any additional facets you don't want (e.g. that don't
>>>> match the initial query term).
>>>>
>>>> Maybe you can write what you see now, with what you
>>>> want to help clarify.
>>>>
>>>> On 06/21/2011 09:47 PM, Bill Bell wrote:
>>>>> I have a field: specialties that is multiValued.
>>>>>
>>>>> It indicates the doctor's specialties: cardiologist, internist, etc.
>>>>>
>>>>> When someone does a search: "Cardiologist", I use
>>>>>
>>>>> q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=spe
>>>>> ci
>>>>> alt
>>>>> ies
>>>>>
>>>>> What I want to come out in the facet is the Cardiologist (since it
>>>>> matches
>>>>> exactly) and the number that matches: 700.
>>>>> I don't want to see the other values that are not Cardiologist.
>>>>>
>>>>> Now I see:
>>>>>
>>>>> Cardiologist: 700
>>>>> Internist: 45
>>>>> Family Doctor: 20
>>>>>
>>>>> This means that several Cardiologist's are also internists and family
>>>>> doctors. When it matches exactly, I don't want to see Internists,
>>> Family
>>>>> Doctors. How do I send a query to Solr with a condition.
>>>>> Facet.query=specialties:Cardiologist&facet.field=specialties
>>>>>
>>>>> Then if the query returns something use it, otherwise use the field
>>> one?
>>>>> Other ideas?
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>


Re: MultiValued facet behavior question

Posted by Bill Bell <bi...@gmail.com>.
Here is an example using exampledocs and trunk 4.0:

http://localhost:8983/solr/select/?q=cat:%22hard%20drive%22&version=2.2&sta
rt=0&rows=10&indent=on&facet=true&facet.field=cat&facet.query={!lucene}cat:
%22hard%20drive%22&facet.mincount=1

Results:

<result name="response" numFound="2" start="0">
Etc....
<lst name="facet_queries">
<int name="{!lucene}cat:"hard drive"">2</int>
</lst>
<lst name="facet_fields">
<lst name="cat">
    <int name="electronics">2</int>
    <int name="hard drive">2</int>
</lst></lst>

Notice that the facet_queries count "2" is the same as the the numFound=2.

But I have no way to use facet.field to count the matches.

The algorithm -

Loop through multiValued field and match on "hard drive". Ignore other
values in there when setting the facet list....




On 6/22/11 1:19 AM, "Dennis de Boer" <da...@gmail.com> wrote:

>Hi Bill,
>
>yes, you absolutely do make sense. I posted the exact same question to
>this
>mailing list (subject: faceting on multivalued fields), but got no
>response
>out of it. A friend of mine is now helping out.
>
>I hope someone on the list can give us some advice. I'll post our findings
>to this topic.
>
>Regards,
>Dennis
>
>
>On Wed, Jun 22, 2011 at 5:37 AM, Bill Bell <bi...@gmail.com> wrote:
>
>> Doing it with q=specialities:Cardiologist or
>> q=Cardiologist&defType=dismax&qf=specialties
>> does not matter, the issue is how I see facets. I want the facets to
>>only
>> show the one match,
>> and not all the multiValued fields in specialties that match...
>>
>> Example,
>>
>> Name|specialties
>> Bell|Cardiologist
>> Smith|Cardiologist,Family Doctor
>> Adams,Cardiologist,Family Doctor,Internist
>>
>> When I facet.field=specialties I get:
>>
>> Cardiologist: 3
>> Internist: 1
>> Family Doctor: 1
>>
>>
>> I only want it to return:
>>
>> Cardiologist: 3
>>
>> Because this matches exactly... Facet on the field that matches and only
>> return the number for that.
>>
>> It can get more complicated. Here is another example:
>>
>> q=cardiology&defType=dismax&qf=specialties
>>
>>
>> (Cardiology and cardiologist are stems)...
>>
>> But I don't really know which value in Cardiologist match perfectly.
>>
>> Again, I only want it to return:
>>
>> Cardiologist: 3
>>
>> If I searched on q=internist&defType=dismax&qf=specialties, I want the
>> result to be:
>>
>>
>> Internist: 1
>>
>>
>> Does this all make sense?
>>
>>
>>
>>
>>
>>
>>
>> On 6/21/11 8:23 PM, "Darren Govoni" <da...@ontrenet.com> wrote:
>>
>> >So are you saying that for all results for "cardiologist",
>> >you don't want facets not matching "Cardiologist" to be
>> >returned as facets?
>> >
>> >what happens when you make q=specialities:Cardiologist?
>> >instead of just q=Cardiologist?
>> >
>> >Seems that if you make the query on the field, then all
>> >your results will necessarily qualify and you can discard
>> >any additional facets you don't want (e.g. that don't
>> >match the initial query term).
>> >
>> >Maybe you can write what you see now, with what you
>> >want to help clarify.
>> >
>> >On 06/21/2011 09:47 PM, Bill Bell wrote:
>> >> I have a field: specialties that is multiValued.
>> >>
>> >> It indicates the doctor's specialties: cardiologist, internist, etc.
>> >>
>> >> When someone does a search: "Cardiologist", I use
>> >>
>> 
>>>>q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=spe
>>>>ci
>> >>alt
>> >> ies
>> >>
>> >> What I want to come out in the facet is the Cardiologist (since it
>> >>matches
>> >> exactly) and the number that matches: 700.
>> >> I don't want to see the other values that are not Cardiologist.
>> >>
>> >> Now I see:
>> >>
>> >> Cardiologist: 700
>> >> Internist: 45
>> >> Family Doctor: 20
>> >>
>> >> This means that several Cardiologist's are also internists and family
>> >> doctors. When it matches exactly, I don't want to see Internists,
>>Family
>> >> Doctors. How do I send a query to Solr with a condition.
>> >> Facet.query=specialties:Cardiologist&facet.field=specialties
>> >>
>> >> Then if the query returns something use it, otherwise use the field
>>one?
>> >>
>> >> Other ideas?
>> >>
>> >>
>> >>
>> >>
>> >
>>
>>
>>



Re: MultiValued facet behavior question

Posted by Dennis de Boer <da...@gmail.com>.
Hi Bill,

yes, you absolutely do make sense. I posted the exact same question to this
mailing list (subject: faceting on multivalued fields), but got no response
out of it. A friend of mine is now helping out.

I hope someone on the list can give us some advice. I'll post our findings
to this topic.

Regards,
Dennis


On Wed, Jun 22, 2011 at 5:37 AM, Bill Bell <bi...@gmail.com> wrote:

> Doing it with q=specialities:Cardiologist or
> q=Cardiologist&defType=dismax&qf=specialties
> does not matter, the issue is how I see facets. I want the facets to only
> show the one match,
> and not all the multiValued fields in specialties that match...
>
> Example,
>
> Name|specialties
> Bell|Cardiologist
> Smith|Cardiologist,Family Doctor
> Adams,Cardiologist,Family Doctor,Internist
>
> When I facet.field=specialties I get:
>
> Cardiologist: 3
> Internist: 1
> Family Doctor: 1
>
>
> I only want it to return:
>
> Cardiologist: 3
>
> Because this matches exactly... Facet on the field that matches and only
> return the number for that.
>
> It can get more complicated. Here is another example:
>
> q=cardiology&defType=dismax&qf=specialties
>
>
> (Cardiology and cardiologist are stems)...
>
> But I don't really know which value in Cardiologist match perfectly.
>
> Again, I only want it to return:
>
> Cardiologist: 3
>
> If I searched on q=internist&defType=dismax&qf=specialties, I want the
> result to be:
>
>
> Internist: 1
>
>
> Does this all make sense?
>
>
>
>
>
>
>
> On 6/21/11 8:23 PM, "Darren Govoni" <da...@ontrenet.com> wrote:
>
> >So are you saying that for all results for "cardiologist",
> >you don't want facets not matching "Cardiologist" to be
> >returned as facets?
> >
> >what happens when you make q=specialities:Cardiologist?
> >instead of just q=Cardiologist?
> >
> >Seems that if you make the query on the field, then all
> >your results will necessarily qualify and you can discard
> >any additional facets you don't want (e.g. that don't
> >match the initial query term).
> >
> >Maybe you can write what you see now, with what you
> >want to help clarify.
> >
> >On 06/21/2011 09:47 PM, Bill Bell wrote:
> >> I have a field: specialties that is multiValued.
> >>
> >> It indicates the doctor's specialties: cardiologist, internist, etc.
> >>
> >> When someone does a search: "Cardiologist", I use
> >>
> >>q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=speci
> >>alt
> >> ies
> >>
> >> What I want to come out in the facet is the Cardiologist (since it
> >>matches
> >> exactly) and the number that matches: 700.
> >> I don't want to see the other values that are not Cardiologist.
> >>
> >> Now I see:
> >>
> >> Cardiologist: 700
> >> Internist: 45
> >> Family Doctor: 20
> >>
> >> This means that several Cardiologist's are also internists and family
> >> doctors. When it matches exactly, I don't want to see Internists, Family
> >> Doctors. How do I send a query to Solr with a condition.
> >> Facet.query=specialties:Cardiologist&facet.field=specialties
> >>
> >> Then if the query returns something use it, otherwise use the field one?
> >>
> >> Other ideas?
> >>
> >>
> >>
> >>
> >
>
>
>

Re: MultiValued facet behavior question

Posted by lee carroll <le...@googlemail.com>.
Oh sorry forgot to also type:
Often facet fields are not stemmed or heavily analysed. The facet
values are from the index.


On 22 June 2011 08:21, lee carroll <le...@googlemail.com> wrote:
> Can your front end app normalize the q parameter. Either with a drop
> down or a type a head derived from the values in the specialties
> field. that way q will match value(s) in your facet results. I'm not
> sure what you are trying to achieve though so maybe i'm off the mark.
>
>
>
> On 22 June 2011 04:37, Bill Bell <bi...@gmail.com> wrote:
>> Doing it with q=specialities:Cardiologist or
>> q=Cardiologist&defType=dismax&qf=specialties
>> does not matter, the issue is how I see facets. I want the facets to only
>> show the one match,
>> and not all the multiValued fields in specialties that match...
>>
>> Example,
>>
>> Name|specialties
>> Bell|Cardiologist
>> Smith|Cardiologist,Family Doctor
>> Adams,Cardiologist,Family Doctor,Internist
>>
>> When I facet.field=specialties I get:
>>
>> Cardiologist: 3
>> Internist: 1
>> Family Doctor: 1
>>
>>
>> I only want it to return:
>>
>> Cardiologist: 3
>>
>> Because this matches exactly... Facet on the field that matches and only
>> return the number for that.
>>
>> It can get more complicated. Here is another example:
>>
>> q=cardiology&defType=dismax&qf=specialties
>>
>>
>> (Cardiology and cardiologist are stems)...
>>
>> But I don't really know which value in Cardiologist match perfectly.
>>
>> Again, I only want it to return:
>>
>> Cardiologist: 3
>>
>> If I searched on q=internist&defType=dismax&qf=specialties, I want the
>> result to be:
>>
>>
>> Internist: 1
>>
>>
>> Does this all make sense?
>>
>>
>>
>>
>>
>>
>>
>> On 6/21/11 8:23 PM, "Darren Govoni" <da...@ontrenet.com> wrote:
>>
>>>So are you saying that for all results for "cardiologist",
>>>you don't want facets not matching "Cardiologist" to be
>>>returned as facets?
>>>
>>>what happens when you make q=specialities:Cardiologist?
>>>instead of just q=Cardiologist?
>>>
>>>Seems that if you make the query on the field, then all
>>>your results will necessarily qualify and you can discard
>>>any additional facets you don't want (e.g. that don't
>>>match the initial query term).
>>>
>>>Maybe you can write what you see now, with what you
>>>want to help clarify.
>>>
>>>On 06/21/2011 09:47 PM, Bill Bell wrote:
>>>> I have a field: specialties that is multiValued.
>>>>
>>>> It indicates the doctor's specialties: cardiologist, internist, etc.
>>>>
>>>> When someone does a search: "Cardiologist", I use
>>>>
>>>>q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=speci
>>>>alt
>>>> ies
>>>>
>>>> What I want to come out in the facet is the Cardiologist (since it
>>>>matches
>>>> exactly) and the number that matches: 700.
>>>> I don't want to see the other values that are not Cardiologist.
>>>>
>>>> Now I see:
>>>>
>>>> Cardiologist: 700
>>>> Internist: 45
>>>> Family Doctor: 20
>>>>
>>>> This means that several Cardiologist's are also internists and family
>>>> doctors. When it matches exactly, I don't want to see Internists, Family
>>>> Doctors. How do I send a query to Solr with a condition.
>>>> Facet.query=specialties:Cardiologist&facet.field=specialties
>>>>
>>>> Then if the query returns something use it, otherwise use the field one?
>>>>
>>>> Other ideas?
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>

Re: MultiValued facet behavior question

Posted by lee carroll <le...@googlemail.com>.
Can your front end app normalize the q parameter. Either with a drop
down or a type a head derived from the values in the specialties
field. that way q will match value(s) in your facet results. I'm not
sure what you are trying to achieve though so maybe i'm off the mark.



On 22 June 2011 04:37, Bill Bell <bi...@gmail.com> wrote:
> Doing it with q=specialities:Cardiologist or
> q=Cardiologist&defType=dismax&qf=specialties
> does not matter, the issue is how I see facets. I want the facets to only
> show the one match,
> and not all the multiValued fields in specialties that match...
>
> Example,
>
> Name|specialties
> Bell|Cardiologist
> Smith|Cardiologist,Family Doctor
> Adams,Cardiologist,Family Doctor,Internist
>
> When I facet.field=specialties I get:
>
> Cardiologist: 3
> Internist: 1
> Family Doctor: 1
>
>
> I only want it to return:
>
> Cardiologist: 3
>
> Because this matches exactly... Facet on the field that matches and only
> return the number for that.
>
> It can get more complicated. Here is another example:
>
> q=cardiology&defType=dismax&qf=specialties
>
>
> (Cardiology and cardiologist are stems)...
>
> But I don't really know which value in Cardiologist match perfectly.
>
> Again, I only want it to return:
>
> Cardiologist: 3
>
> If I searched on q=internist&defType=dismax&qf=specialties, I want the
> result to be:
>
>
> Internist: 1
>
>
> Does this all make sense?
>
>
>
>
>
>
>
> On 6/21/11 8:23 PM, "Darren Govoni" <da...@ontrenet.com> wrote:
>
>>So are you saying that for all results for "cardiologist",
>>you don't want facets not matching "Cardiologist" to be
>>returned as facets?
>>
>>what happens when you make q=specialities:Cardiologist?
>>instead of just q=Cardiologist?
>>
>>Seems that if you make the query on the field, then all
>>your results will necessarily qualify and you can discard
>>any additional facets you don't want (e.g. that don't
>>match the initial query term).
>>
>>Maybe you can write what you see now, with what you
>>want to help clarify.
>>
>>On 06/21/2011 09:47 PM, Bill Bell wrote:
>>> I have a field: specialties that is multiValued.
>>>
>>> It indicates the doctor's specialties: cardiologist, internist, etc.
>>>
>>> When someone does a search: "Cardiologist", I use
>>>
>>>q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=speci
>>>alt
>>> ies
>>>
>>> What I want to come out in the facet is the Cardiologist (since it
>>>matches
>>> exactly) and the number that matches: 700.
>>> I don't want to see the other values that are not Cardiologist.
>>>
>>> Now I see:
>>>
>>> Cardiologist: 700
>>> Internist: 45
>>> Family Doctor: 20
>>>
>>> This means that several Cardiologist's are also internists and family
>>> doctors. When it matches exactly, I don't want to see Internists, Family
>>> Doctors. How do I send a query to Solr with a condition.
>>> Facet.query=specialties:Cardiologist&facet.field=specialties
>>>
>>> Then if the query returns something use it, otherwise use the field one?
>>>
>>> Other ideas?
>>>
>>>
>>>
>>>
>>
>
>
>

RE: MultiValued facet behavior question

Posted by nicopost <ni...@area52.nl>.
Thanks Robert, your code helped me solve a problem I had! Saved me a lot of
time & headaches

cheers,  Nico



--
View this message in context: http://lucene.472066.n3.nabble.com/MultiValued-facet-behavior-question-tp3093851p4022375.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: MultiValued facet behavior question

Posted by Jonathan Rochkind <ro...@jhu.edu>.
Okay, so since you put "cardiologist" in the 'q', you only want facet 
values that have 'cardiologist' (or 'Cardiologist') to show in up the 
facet list.

In general, there's no good way to do that.

But.

If you want to do some client-side processing before you submit the 
query to Solr, and on the client side you can figure out exactly what 
you want: then you could try to play around with facet.filter or 
facet.query, to see if you can make it do what you want. It may or may 
not work out, depending on exactly your use pattern, which you still 
haven't articulated very well, but you can mess around with it and see 
what you can do.

Ie, if you KNOW (that is, your own app code knows, when creating the 
Solr request) that you only want the facet value for "Cardiologist" 
(including exact case), you can try facet.query=specialty:Cardiologist

Your app code would have to pull out the results special too, they won't 
be in the Solr response in same way ordinary facet.field is. It also 
requires your query value to match _exactly_ (case, punctuation, etc) 
the value in the index. Not "cardiologist" and "Cardiologist".

I think Solr 3.1 has some regex based facet.filter abilities that might 
be useful, and help you get around the 'exact match' issues, but watch 
out for performance.




On 6/21/2011 11:37 PM, Bill Bell wrote:
> Doing it with q=specialities:Cardiologist or
> q=Cardiologist&defType=dismax&qf=specialties
> does not matter, the issue is how I see facets. I want the facets to only
> show the one match,
> and not all the multiValued fields in specialties that match...
>
> Example,
>
> Name|specialties
> Bell|Cardiologist
> Smith|Cardiologist,Family Doctor
> Adams,Cardiologist,Family Doctor,Internist
>
> When I facet.field=specialties I get:
>
> Cardiologist: 3
> Internist: 1
> Family Doctor: 1
>
>
> I only want it to return:
>
> Cardiologist: 3
>
> Because this matches exactly... Facet on the field that matches and only
> return the number for that.
>
> It can get more complicated. Here is another example:
>
> q=cardiology&defType=dismax&qf=specialties
>
>
> (Cardiology and cardiologist are stems)...
>
> But I don't really know which value in Cardiologist match perfectly.
>
> Again, I only want it to return:
>
> Cardiologist: 3
>
> If I searched on q=internist&defType=dismax&qf=specialties, I want the
> result to be:
>
>
> Internist: 1
>
>
> Does this all make sense?
>
>
>
>
>
>
>
> On 6/21/11 8:23 PM, "Darren Govoni"<da...@ontrenet.com>  wrote:
>
>> So are you saying that for all results for "cardiologist",
>> you don't want facets not matching "Cardiologist" to be
>> returned as facets?
>>
>> what happens when you make q=specialities:Cardiologist?
>> instead of just q=Cardiologist?
>>
>> Seems that if you make the query on the field, then all
>> your results will necessarily qualify and you can discard
>> any additional facets you don't want (e.g. that don't
>> match the initial query term).
>>
>> Maybe you can write what you see now, with what you
>> want to help clarify.
>>
>> On 06/21/2011 09:47 PM, Bill Bell wrote:
>>> I have a field: specialties that is multiValued.
>>>
>>> It indicates the doctor's specialties: cardiologist, internist, etc.
>>>
>>> When someone does a search: "Cardiologist", I use
>>>
>>> q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=speci
>>> alt
>>> ies
>>>
>>> What I want to come out in the facet is the Cardiologist (since it
>>> matches
>>> exactly) and the number that matches: 700.
>>> I don't want to see the other values that are not Cardiologist.
>>>
>>> Now I see:
>>>
>>> Cardiologist: 700
>>> Internist: 45
>>> Family Doctor: 20
>>>
>>> This means that several Cardiologist's are also internists and family
>>> doctors. When it matches exactly, I don't want to see Internists, Family
>>> Doctors. How do I send a query to Solr with a condition.
>>> Facet.query=specialties:Cardiologist&facet.field=specialties
>>>
>>> Then if the query returns something use it, otherwise use the field one?
>>>
>>> Other ideas?
>>>
>>>
>>>
>>>
>
>

Re: MultiValued facet behavior question

Posted by lee carroll <le...@googlemail.com>.
Hi Bill, can you explain a little bit more around why you need this.
Knowing the motivation
might suggest a different solution not just involving faceting.



On 22 June 2011 08:49, Bill Bell <bi...@gmail.com> wrote:
> You can type q=cardiology and match on cardiologist. If stemming did not
> work you can just add a synonym:
>
> cardiology,cardiologist
>
> But that is not the issue. The issue is around multiValue fields and
> facets. You would expect a user
> Who is searching on the multiValued field to match on some values in
> there. For example,
> they type "Cardiologist" and it matches on the value "Cardiologist". So it
> matches "in the multiValue field".
> So that part works. Then when I output the facet, I need a different
> behavior than the default. I need
> The facet to only output the value that matches (scored) - NOT ALL VALUES
> in the multiValued field.
>
> I think it makes sense?
>
>
> On 6/22/11 1:42 AM, "Michael Kuhlmann" <so...@kuli.org> wrote:
>
>>Am 22.06.2011 05:37, schrieb Bill Bell:
>>> It can get more complicated. Here is another example:
>>>
>>> q=cardiology&defType=dismax&qf=specialties
>>>
>>>
>>> (Cardiology and cardiologist are stems)...
>>>
>>> But I don't really know which value in Cardiologist match perfectly.
>>>
>>> Again, I only want it to return:
>>>
>>> Cardiologist: 3
>>
>>You would never get "Cardiologist: 3" as the facet result, because if
>>"Cardiologist" would be in your index, it's impossible to find it when
>>searching for "cardiology" (except when you manage to write some strange
>>tokenizer that translates "cardiology" to "Cardiologist" on query time,
>>including the upper case letter).
>>
>>Facets are always taken from the index, so they usually match exactly or
>>never when querying for it.
>>
>>-Kuli
>
>
>

RE: MultiValued facet behavior question

Posted by Bob Sandiford <bo...@sirsidynix.com>.
Hi, Bill (and others).

I post this for what it's worth - it's a very specialized resolution we wrote to a similar requirement that may help with your (and similar) requirements.

Caveats abound [1]

We're running 3.1.

We wanted to be able to return facets which matched on our actual search, rather than all facets from the entire result set.  For example, if a user searches for author 'Twain', we present to them a list of facets which match 'Twain', and exclude facets where 'Twain' is not found.  (Now - we don't tell our users that these are 'facet' values - we just present an alpha-sorted list of author names with a count of associated documents) So, we search our Author search field to identify matching documents, get all the facets (i.e. normal Solr processing to this point), and then filter that facet set to include only those that match our original search.


We added our own extra facet parameter (facet.sirsidynix.filter.facets) to instruct Solr when to do this special facet filtering. We modified SimpleFacets method getTermCounts right before the final "return counts;" like this:

      // Custom SirsiDynix code.
      if (params.getBool(FacetParams.FACET_SIRSIDYNIX_FILTER_FACETS, false))
      {
          counts = filterCounts(field, counts);
      }
    return counts;

and added method 'filterCounts()' which is this class, basically wrapping things up to run the search against each facet value, setting up MemoryIndex instances based on our schema, inserting the facet value, and running our original query against the MemoryIndex.  Anything that matches has a score > 0, and those are the only ones we keep:

    /**
     * Custom SirsiDynix code:
     * Filters counts down to only those entries that match the original
     * query.  Does this by using lucene's MemoryIndex - a very fast, in-memory,
     * single document index that can have queries run against it.
     * For each string value in count, we create a MemoryIndex and run the
     * original query against it.  Anything with a score > 0 means a 'hit', so
     * the value matches the original query, and we'll retain it.  Score 0 means
     * no hit (i.e. was a facet value that was associated with a document that matched
     * the query, but the facet value itself didn't match the query).
     * @param field name of the field that the facet values came from.
     * @param counts Lucene's list of facet values.
     * @return filtered set, only those matching the original query.
     */
    private NamedList filterCounts(String field, NamedList counts)
    {
        if (!field.endsWith("_facet"))
        {
            return counts;
        }
        // Trim off "_facet"
        String fieldBase = field.substring(0,field.length() - 6);
        // Builds fields to search against.
        // Note that original came from (e.g.) AUTHOR_facet.
        // And, original search would have been for INITIAL_AUTHOR_SRCH_boost as well as
        // SUBSEQUENT_AUTHOR_SRCH_boost (and fuzzy's).  However, we're only searching
        // one string at a time, so we'll shove it into the single-values INITIAL_xxx
        // fields.  That will be good enough for the Query to be able to correctly
        // evaluate against the document.
        String fieldBoost = "INITIAL_" + fieldBase + "_SRCH_boost";
        String fieldFuzzy = "INITIAL_" + fieldBase + "_SRCH_fuzzy";
        NamedList newCounts = new NamedList();

        IndexSchema schema = searcher.getSchema();
        SchemaField schemaField = schema.getField(fieldBoost);
        FieldType fieldType = schemaField.getType();
        Analyzer fieldAnalyzer = fieldType.getAnalyzer();

        SchemaField schemaFuzzyField = schema.getField(fieldFuzzy);
        FieldType fuzzyFieldType = schemaFuzzyField.getType();
        Analyzer fuzzyFieldAnalyzer = fuzzyFieldType.getAnalyzer();

        for (int i = 0; i < counts.size(); i++)
        {
            String testValue = counts.getName(i);
            MemoryIndex index = new MemoryIndex();
            index.addField(fieldBoost, testValue, fieldAnalyzer);
            index.addField(fieldFuzzy, testValue, fuzzyFieldAnalyzer);
            float score = index.search(rb.getQuery());
            if (score > 0.0f)
            {
                newCounts.add(testValue, counts.getVal(i));
            }
        }

        return newCounts;
    }

A bit of explanation on our schema will be in order here.

1) We've suffixed all our facet fields with "_facet" - hence that first if statement.
2) We have matching 'searchable' and 'facet' fields, names basically differ only in the suffix.  So, we strip off '_facet' and append '_boost' and '_fuzzy' (our two field types for searching against (and possibly applying boosts), and doing fuzzy matching against).  (You'll see it's not exactly that - but you can hopefully modify your version to match your schema)  Basically the idea is that we can derive the field name(s) against which the original search was issued from the facet field name.
3) You'll want to read up on the MemoryIndex class to see more about how it works, rather than me re-iterating that here.

[1] Caveats
1) We didn't do anything with the date type faceting, or with any ranges.
2) We didn't do anything with Facet prefix handling - it may or may not work if you need prefixes.
3) Anything else that facets do that we didn't handle - or at least, didn't test :)  As I say, it's a very special case for us, and this is in no way intended to be a general solution or fit for 'prime time' submission as a Solr enhancement.

Bob Sandiford | Lead Software Engineer | SirsiDynix
P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
www.sirsidynix.com

> -----Original Message-----
> From: Bill Bell [mailto:billnbell@gmail.com]
> Sent: Wednesday, June 22, 2011 3:49 AM
> To: solr-user@lucene.apache.org
> Subject: Re: MultiValued facet behavior question
> 
> You can type q=cardiology and match on cardiologist. If stemming did
> not
> work you can just add a synonym:
> 
> cardiology,cardiologist
> 
> But that is not the issue. The issue is around multiValue fields and
> facets. You would expect a user
> Who is searching on the multiValued field to match on some values in
> there. For example,
> they type "Cardiologist" and it matches on the value "Cardiologist". So
> it
> matches "in the multiValue field".
> So that part works. Then when I output the facet, I need a different
> behavior than the default. I need
> The facet to only output the value that matches (scored) - NOT ALL
> VALUES
> in the multiValued field.
> 
> I think it makes sense?
> 
> 
> On 6/22/11 1:42 AM, "Michael Kuhlmann" <so...@kuli.org> wrote:
> 
> >Am 22.06.2011 05:37, schrieb Bill Bell:
> >> It can get more complicated. Here is another example:
> >>
> >> q=cardiology&defType=dismax&qf=specialties
> >>
> >>
> >> (Cardiology and cardiologist are stems)...
> >>
> >> But I don't really know which value in Cardiologist match perfectly.
> >>
> >> Again, I only want it to return:
> >>
> >> Cardiologist: 3
> >
> >You would never get "Cardiologist: 3" as the facet result, because if
> >"Cardiologist" would be in your index, it's impossible to find it when
> >searching for "cardiology" (except when you manage to write some
> strange
> >tokenizer that translates "cardiology" to "Cardiologist" on query
> time,
> >including the upper case letter).
> >
> >Facets are always taken from the index, so they usually match exactly
> or
> >never when querying for it.
> >
> >-Kuli
> 
> 



Re: MultiValued facet behavior question

Posted by Mike Sokolov <so...@ifactory.com>.
On 06/22/2011 04:01 AM, Dennis de Boer wrote:
> Hi Bill,
>
> as far as I understood now, with the help of my friend, you can't.
> Multivalued fields don't work that way.
> You can however always filter the facet results manually in the JSP. You
> knwo what the user chose as a facet.
>    
Yes - that is the most sensible suggestion: if you want to display the 
facets the user chose, and only those, regardless of what was found in 
the index, then I think you know what to do!
> The issue I ran into is when you have additional facet fields. For example
> when you also have country as a facetfield. Now when you search for
> Cardiologist, it also returns Internist and family doctor as you described.
> What Sorl now also returns for the country list are the countries for
> Cardiologist, but also for Internist  and family doctor. This is not what
> you want.
>    
I don't think this is accurate.  Your query matches some set of 
documents - the facet values shown will only be those that occur in that 
set.  If some internist's countries are shown when the user selects 
Cardiologist, that is because those internists are aldo cardiologists, 
right?

-Mike

Re: MultiValued facet behavior question

Posted by Dennis de Boer <da...@gmail.com>.
Hi Bill,

as far as I understood now, with the help of my friend, you can't.
Multivalued fields don't work that way.
You can however always filter the facet results manually in the JSP. You
knwo what the user chose as a facet.

The issue I ran into is when you have additional facet fields. For example
when you also have country as a facetfield. Now when you search for
Cardiologist, it also returns Internist and family doctor as you described.
What Sorl now also returns for the country list are the countries for
Cardiologist, but also for Internist  and family doctor. This is not what
you want.

I don't think what we want her is supported out of the box by solr.


Regards,
Dennis


On Wed, Jun 22, 2011 at 9:49 AM, Bill Bell <bi...@gmail.com> wrote:

> You can type q=cardiology and match on cardiologist. If stemming did not
> work you can just add a synonym:
>
> cardiology,cardiologist
>
> But that is not the issue. The issue is around multiValue fields and
> facets. You would expect a user
> Who is searching on the multiValued field to match on some values in
> there. For example,
> they type "Cardiologist" and it matches on the value "Cardiologist". So it
> matches "in the multiValue field".
> So that part works. Then when I output the facet, I need a different
> behavior than the default. I need
> The facet to only output the value that matches (scored) - NOT ALL VALUES
> in the multiValued field.
>
> I think it makes sense?
>
>
> On 6/22/11 1:42 AM, "Michael Kuhlmann" <so...@kuli.org> wrote:
>
> >Am 22.06.2011 05:37, schrieb Bill Bell:
> >> It can get more complicated. Here is another example:
> >>
> >> q=cardiology&defType=dismax&qf=specialties
> >>
> >>
> >> (Cardiology and cardiologist are stems)...
> >>
> >> But I don't really know which value in Cardiologist match perfectly.
> >>
> >> Again, I only want it to return:
> >>
> >> Cardiologist: 3
> >
> >You would never get "Cardiologist: 3" as the facet result, because if
> >"Cardiologist" would be in your index, it's impossible to find it when
> >searching for "cardiology" (except when you manage to write some strange
> >tokenizer that translates "cardiology" to "Cardiologist" on query time,
> >including the upper case letter).
> >
> >Facets are always taken from the index, so they usually match exactly or
> >never when querying for it.
> >
> >-Kuli
>
>
>

Re: MultiValued facet behavior question

Posted by Chris Hostetter <ho...@fucit.org>.
: And I click on B, does it make sense for the user to display
: B
: C
: E
: 
: after the selection ? Just because items in B are C and E items as well?
: As A user I chose B because I'm interested in B items. I do not care if they
: are also C and E items.
: Technically this is correct, but functional wise, the user doesn't care
: because it is not what they searched for.

if that's how you want your UI to behavior, then it should be trivial to 
say "once the user clicks on a constraint in the $fieldName field, stop 
displaying facets for $fieldName" -- ie: if you add 
fq=$fieldName:fieldValue to your URL, then don't add 
facet.field=$fieldName to that same URL.

If you want the same behavior anytime the users query inadvertantly 
*happens* to be a query that only matches one of many values in a 
mutifaceted field (ie: the user searches for "brown hair" and all brown 
haired docors just happen to be cardiologiests) then you can still deal 
with this in your UI code by implementing logic such as: 

  * check the numFound for the main query
  * for each facet:
    * for each constraint:
      * if the constraint count is the same as numFound, skip this facet


-Hoss

Re: MultiValued facet behavior question

Posted by Mike Sokolov <so...@ifactory.com>.
We always remove the facet filter when faceting: in other words, for a 
good user experience, you generally want to show facets based on the 
query excluding any restriction based on the facets.
So in your example (facet B selected), we would continue to show *all* 
facets.  Only if you performed a search using some other filter 
(proximity, gender, etc), would we restrict the facet list.

-Mike

On 06/22/2011 09:42 AM, Dennis de Boer wrote:
> Well, the use case is rather simple. It is not a use case but more auser
> experience.
>
> If I have a list of values I can facet on, for example :
> A
> B
> C
> D
> E
>
> And I click on B, does it make sense for the user to display
> B
> C
> E
>
> after the selection ? Just because items in B are C and E items as well?
> As A user I chose B because I'm interested in B items. I do not care if they
> are also C and E items.
> Technically this is correct, but functional wise, the user doesn't care
> because it is not what they searched for.
>
> In this case they were searching for a Cardiologists. Do I care that a
> cardiologist is also a family doctor? No. So I also do not want to see this
> as a facet value presented to me in frontend logic.
> In the item details you can show that the cardiologist is also a family
> doctor. That is fine, but not as an availbale facet option, if you just
> chose an speciality you want to filter on.
>
> Does it make sense?
>
>
> On Wed, Jun 22, 2011 at 3:31 PM, lee carroll
> <le...@googlemail.com>wrote:
>
>    
>> Hi Dennis,
>>
>> I think maybe I just disagree. Your not showing facet counts for
>> cardiologists and Family Doctors independently. The Family Doctor
>> count will be all Family Doctors who are also Cardiologists.
>>
>> This allows users to further filter Cardiologists who are also family
>> Doctors. (this could be of use to them ??)
>>
>> If your front end app implements the filtering as a list of fq=xxx
>> then that would make for consistent results ?
>>
>> I don't see how not showing that some cardiologists are also Family
>> Doctors is a better user experience... But again you might have a very
>> specific use case?
>>
>> On 22 June 2011 13:44, Dennis de Boer<da...@gmail.com>  wrote:
>>      
>>> Hi Lee,
>>>
>>> since I have the same problem, I might as well try to answer this
>>>        
>> question.
>>      
>>> You want this behaviour to make things clear for your users. If they
>>>        
>> select
>>      
>>> cardiologists, does it make sense to also show family doctors as a
>>> facetvalue to the user.
>>> The same thing goed for the facets that are related to family doctors.
>>>        
>> They
>>      
>>> are returned as well, thus making it even moren unclear for the end-user.
>>>
>>>
>>>
>>> On Wed, Jun 22, 2011 at 2:27 PM, lee carroll
>>> <le...@googlemail.com>wrote:
>>>
>>>        
>>>> Hi Bill,
>>>>
>>>>          
>>>>> So that part works. Then when I output the facet, I need a different
>>>>> behavior than the default. I need
>>>>> The facet to only output the value that matches (scored) - NOT ALL
>>>>>            
>> VALUES
>>      
>>>>> in the multiValued field.
>>>>>            
>>>>          
>>>>> I think it makes sense?
>>>>>            
>>>> Why do you need this ? If your use case is faceted navigation then not
>>>> showing
>>>> all the facet terms which match your query would be mis-leading to your
>>>> users.
>>>> The fact is your data indicates Ben the cardiologist is also a GP etc.
>>>> Is it not valid for
>>>> your users to be able to further filter on cardiologists who are also
>>>> specialists in x other disciplines ? If the specialisms are mutually
>>>> exclusive then your data will reflect this.
>>>>
>>>> The fact is x number of cardiologists match and x number of GP's match
>>>>          
>> etc
>>      
>>>> I may be missing the point here as you have not said why you need to do
>>>> this ?
>>>>
>>>> cheers lee c
>>>>
>>>>
>>>> On 22 June 2011 09:34, Michael Kuhlmann<so...@kuli.org>  wrote:
>>>>          
>>>>> Am 22.06.2011 09:49, schrieb Bill Bell:
>>>>>            
>>>>>> You can type q=cardiology and match on cardiologist. If stemming did
>>>>>>              
>> not
>>      
>>>>>> work you can just add a synonym:
>>>>>>
>>>>>> cardiology,cardiologist
>>>>>>              
>>>>> Okay, synonyms are the only way I can think of a realistic match.
>>>>>
>>>>> Stemming won't work on a facet field; you wouldn't get "Cardiologist:
>>>>>            
>> 3"
>>      
>>>>> as the result but "cardiolog: 3" or something like that instead.
>>>>>
>>>>> Normally, you use declare facet field explicitly for facetting, and
>>>>>            
>> not
>>      
>>>>> for searching, exactly because stemming and tokenizing on facet fields
>>>>> don't make sense.
>>>>>
>>>>> And the short answer is: No, that's not possible.
>>>>>
>>>>> -Kuli
>>>>>
>>>>>            
>>>>          
>>>        
>>      
>    

Re: MultiValued facet behavior question

Posted by Dennis de Boer <da...@gmail.com>.
Well, the use case is rather simple. It is not a use case but more auser
experience.

If I have a list of values I can facet on, for example :
A
B
C
D
E

And I click on B, does it make sense for the user to display
B
C
E

after the selection ? Just because items in B are C and E items as well?
As A user I chose B because I'm interested in B items. I do not care if they
are also C and E items.
Technically this is correct, but functional wise, the user doesn't care
because it is not what they searched for.

In this case they were searching for a Cardiologists. Do I care that a
cardiologist is also a family doctor? No. So I also do not want to see this
as a facet value presented to me in frontend logic.
In the item details you can show that the cardiologist is also a family
doctor. That is fine, but not as an availbale facet option, if you just
chose an speciality you want to filter on.

Does it make sense?


On Wed, Jun 22, 2011 at 3:31 PM, lee carroll
<le...@googlemail.com>wrote:

> Hi Dennis,
>
> I think maybe I just disagree. Your not showing facet counts for
> cardiologists and Family Doctors independently. The Family Doctor
> count will be all Family Doctors who are also Cardiologists.
>
> This allows users to further filter Cardiologists who are also family
> Doctors. (this could be of use to them ??)
>
> If your front end app implements the filtering as a list of fq=xxx
> then that would make for consistent results ?
>
> I don't see how not showing that some cardiologists are also Family
> Doctors is a better user experience... But again you might have a very
> specific use case?
>
> On 22 June 2011 13:44, Dennis de Boer <da...@gmail.com> wrote:
> > Hi Lee,
> >
> > since I have the same problem, I might as well try to answer this
> question.
> >
> > You want this behaviour to make things clear for your users. If they
> select
> > cardiologists, does it make sense to also show family doctors as a
> > facetvalue to the user.
> > The same thing goed for the facets that are related to family doctors.
> They
> > are returned as well, thus making it even moren unclear for the end-user.
> >
> >
> >
> > On Wed, Jun 22, 2011 at 2:27 PM, lee carroll
> > <le...@googlemail.com>wrote:
> >
> >> Hi Bill,
> >>
> >> >So that part works. Then when I output the facet, I need a different
> >> >behavior than the default. I need
> >> >The facet to only output the value that matches (scored) - NOT ALL
> VALUES
> >> >in the multiValued field.
> >>
> >> >I think it makes sense?
> >>
> >> Why do you need this ? If your use case is faceted navigation then not
> >> showing
> >> all the facet terms which match your query would be mis-leading to your
> >> users.
> >> The fact is your data indicates Ben the cardiologist is also a GP etc.
> >> Is it not valid for
> >> your users to be able to further filter on cardiologists who are also
> >> specialists in x other disciplines ? If the specialisms are mutually
> >> exclusive then your data will reflect this.
> >>
> >> The fact is x number of cardiologists match and x number of GP's match
> etc
> >>
> >> I may be missing the point here as you have not said why you need to do
> >> this ?
> >>
> >> cheers lee c
> >>
> >>
> >> On 22 June 2011 09:34, Michael Kuhlmann <so...@kuli.org> wrote:
> >> > Am 22.06.2011 09:49, schrieb Bill Bell:
> >> >> You can type q=cardiology and match on cardiologist. If stemming did
> not
> >> >> work you can just add a synonym:
> >> >>
> >> >> cardiology,cardiologist
> >> >
> >> > Okay, synonyms are the only way I can think of a realistic match.
> >> >
> >> > Stemming won't work on a facet field; you wouldn't get "Cardiologist:
> 3"
> >> > as the result but "cardiolog: 3" or something like that instead.
> >> >
> >> > Normally, you use declare facet field explicitly for facetting, and
> not
> >> > for searching, exactly because stemming and tokenizing on facet fields
> >> > don't make sense.
> >> >
> >> > And the short answer is: No, that's not possible.
> >> >
> >> > -Kuli
> >> >
> >>
> >
>

Re: MultiValued facet behavior question

Posted by Gino Rodrigues <gi...@gmail.com>.
An interesting live scenario for this matter:
http://www.bondfaro.com.br/  (brazilian site)

The query "ipad" returns results spread across many categories (links
on the left, teasers in the center). The "Tablet" category (facet) is
one of them.

The query "tablet" does exactly the same as clicking "Tablet" in the
search for "ipad". Note the breadcrumb
(Início>Informática>Tablet>tablet)

In this case of a broad term, that exactly matches a product facet, it
totally makes sense for the user. In general, it tends to make more
sense as the search bias from full-text to structured metadata.

So, is it possible to turn "q=cardiologist" into
"q=specialities:Cardiologist" by boosting an exact match on a facet
label?

Re: MultiValued facet behavior question

Posted by Darren Govoni <da...@ontrenet.com>.
Yeah, I agree with that last statement.

It seems to me that the use case where it _might_ matter is where
you have a query for MORE than one.

q=cardiologist OR family

and in that case, it MIGHT be useful to separate the facets
in a XOR sense where you don't get cross-pollution. But
the original poster didn't indicate this scenario originally.

Maybe for that, Solr's grouping mechanism will help?
Although I have not used it myself.

On 06/22/2011 09:31 AM, lee carroll wrote:
> Hi Dennis,
>
> I think maybe I just disagree. Your not showing facet counts for
> cardiologists and Family Doctors independently. The Family Doctor
> count will be all Family Doctors who are also Cardiologists.
>
> This allows users to further filter Cardiologists who are also family
> Doctors. (this could be of use to them ??)
>
> If your front end app implements the filtering as a list of fq=xxx
> then that would make for consistent results ?
>
> I don't see how not showing that some cardiologists are also Family
> Doctors is a better user experience... But again you might have a very
> specific use case?
>
> On 22 June 2011 13:44, Dennis de Boer<da...@gmail.com>  wrote:
>> Hi Lee,
>>
>> since I have the same problem, I might as well try to answer this question.
>>
>> You want this behaviour to make things clear for your users. If they select
>> cardiologists, does it make sense to also show family doctors as a
>> facetvalue to the user.
>> The same thing goed for the facets that are related to family doctors. They
>> are returned as well, thus making it even moren unclear for the end-user.
>>
>>
>>
>> On Wed, Jun 22, 2011 at 2:27 PM, lee carroll
>> <le...@googlemail.com>wrote:
>>
>>> Hi Bill,
>>>
>>>> So that part works. Then when I output the facet, I need a different
>>>> behavior than the default. I need
>>>> The facet to only output the value that matches (scored) - NOT ALL VALUES
>>>> in the multiValued field.
>>>> I think it makes sense?
>>> Why do you need this ? If your use case is faceted navigation then not
>>> showing
>>> all the facet terms which match your query would be mis-leading to your
>>> users.
>>> The fact is your data indicates Ben the cardiologist is also a GP etc.
>>> Is it not valid for
>>> your users to be able to further filter on cardiologists who are also
>>> specialists in x other disciplines ? If the specialisms are mutually
>>> exclusive then your data will reflect this.
>>>
>>> The fact is x number of cardiologists match and x number of GP's match etc
>>>
>>> I may be missing the point here as you have not said why you need to do
>>> this ?
>>>
>>> cheers lee c
>>>
>>>
>>> On 22 June 2011 09:34, Michael Kuhlmann<so...@kuli.org>  wrote:
>>>> Am 22.06.2011 09:49, schrieb Bill Bell:
>>>>> You can type q=cardiology and match on cardiologist. If stemming did not
>>>>> work you can just add a synonym:
>>>>>
>>>>> cardiology,cardiologist
>>>> Okay, synonyms are the only way I can think of a realistic match.
>>>>
>>>> Stemming won't work on a facet field; you wouldn't get "Cardiologist: 3"
>>>> as the result but "cardiolog: 3" or something like that instead.
>>>>
>>>> Normally, you use declare facet field explicitly for facetting, and not
>>>> for searching, exactly because stemming and tokenizing on facet fields
>>>> don't make sense.
>>>>
>>>> And the short answer is: No, that's not possible.
>>>>
>>>> -Kuli
>>>>


Re: MultiValued facet behavior question

Posted by lee carroll <le...@googlemail.com>.
Hi Dennis,

I think maybe I just disagree. Your not showing facet counts for
cardiologists and Family Doctors independently. The Family Doctor
count will be all Family Doctors who are also Cardiologists.

This allows users to further filter Cardiologists who are also family
Doctors. (this could be of use to them ??)

If your front end app implements the filtering as a list of fq=xxx
then that would make for consistent results ?

I don't see how not showing that some cardiologists are also Family
Doctors is a better user experience... But again you might have a very
specific use case?

On 22 June 2011 13:44, Dennis de Boer <da...@gmail.com> wrote:
> Hi Lee,
>
> since I have the same problem, I might as well try to answer this question.
>
> You want this behaviour to make things clear for your users. If they select
> cardiologists, does it make sense to also show family doctors as a
> facetvalue to the user.
> The same thing goed for the facets that are related to family doctors. They
> are returned as well, thus making it even moren unclear for the end-user.
>
>
>
> On Wed, Jun 22, 2011 at 2:27 PM, lee carroll
> <le...@googlemail.com>wrote:
>
>> Hi Bill,
>>
>> >So that part works. Then when I output the facet, I need a different
>> >behavior than the default. I need
>> >The facet to only output the value that matches (scored) - NOT ALL VALUES
>> >in the multiValued field.
>>
>> >I think it makes sense?
>>
>> Why do you need this ? If your use case is faceted navigation then not
>> showing
>> all the facet terms which match your query would be mis-leading to your
>> users.
>> The fact is your data indicates Ben the cardiologist is also a GP etc.
>> Is it not valid for
>> your users to be able to further filter on cardiologists who are also
>> specialists in x other disciplines ? If the specialisms are mutually
>> exclusive then your data will reflect this.
>>
>> The fact is x number of cardiologists match and x number of GP's match etc
>>
>> I may be missing the point here as you have not said why you need to do
>> this ?
>>
>> cheers lee c
>>
>>
>> On 22 June 2011 09:34, Michael Kuhlmann <so...@kuli.org> wrote:
>> > Am 22.06.2011 09:49, schrieb Bill Bell:
>> >> You can type q=cardiology and match on cardiologist. If stemming did not
>> >> work you can just add a synonym:
>> >>
>> >> cardiology,cardiologist
>> >
>> > Okay, synonyms are the only way I can think of a realistic match.
>> >
>> > Stemming won't work on a facet field; you wouldn't get "Cardiologist: 3"
>> > as the result but "cardiolog: 3" or something like that instead.
>> >
>> > Normally, you use declare facet field explicitly for facetting, and not
>> > for searching, exactly because stemming and tokenizing on facet fields
>> > don't make sense.
>> >
>> > And the short answer is: No, that's not possible.
>> >
>> > -Kuli
>> >
>>
>

Re: MultiValued facet behavior question

Posted by Dennis de Boer <da...@gmail.com>.
Hi Lee,

since I have the same problem, I might as well try to answer this question.

You want this behaviour to make things clear for your users. If they select
cardiologists, does it make sense to also show family doctors as a
facetvalue to the user.
The same thing goed for the facets that are related to family doctors. They
are returned as well, thus making it even moren unclear for the end-user.



On Wed, Jun 22, 2011 at 2:27 PM, lee carroll
<le...@googlemail.com>wrote:

> Hi Bill,
>
> >So that part works. Then when I output the facet, I need a different
> >behavior than the default. I need
> >The facet to only output the value that matches (scored) - NOT ALL VALUES
> >in the multiValued field.
>
> >I think it makes sense?
>
> Why do you need this ? If your use case is faceted navigation then not
> showing
> all the facet terms which match your query would be mis-leading to your
> users.
> The fact is your data indicates Ben the cardiologist is also a GP etc.
> Is it not valid for
> your users to be able to further filter on cardiologists who are also
> specialists in x other disciplines ? If the specialisms are mutually
> exclusive then your data will reflect this.
>
> The fact is x number of cardiologists match and x number of GP's match etc
>
> I may be missing the point here as you have not said why you need to do
> this ?
>
> cheers lee c
>
>
> On 22 June 2011 09:34, Michael Kuhlmann <so...@kuli.org> wrote:
> > Am 22.06.2011 09:49, schrieb Bill Bell:
> >> You can type q=cardiology and match on cardiologist. If stemming did not
> >> work you can just add a synonym:
> >>
> >> cardiology,cardiologist
> >
> > Okay, synonyms are the only way I can think of a realistic match.
> >
> > Stemming won't work on a facet field; you wouldn't get "Cardiologist: 3"
> > as the result but "cardiolog: 3" or something like that instead.
> >
> > Normally, you use declare facet field explicitly for facetting, and not
> > for searching, exactly because stemming and tokenizing on facet fields
> > don't make sense.
> >
> > And the short answer is: No, that's not possible.
> >
> > -Kuli
> >
>

Re: MultiValued facet behavior question

Posted by William Bell <bi...@gmail.com>.
Let me give the full user case... There has been a little
misunderstanding, but really some good discussions...

1. Some Cardiologists are also Family Doctors and Internal Medicine
doctors (Internist).
2. The use case that confuses the users is the output of the query
when using dismax across 2 fields (search name and specialties, but
when it matches exactly on specialties, someone know that...).

q=Cardiologist&defType=dismax&qf=specialties^1.0
name^2.0&facet=true&facet.field=specialties

numFound=812 but the facet for Cardiologist is 700. The discrepency is
that some are matching soundex...

So they see as specialties:
Cardiologist: 700
Internist: 45
Family Doctor: 20

But since the string "Cardiologist" matches what they type, I would
like it selected and limit to 700.

But if it does not match I want it ignored.

In essence I want: fq=specialties:"what user types" but only if it
matches. It it does not match I want it ignored... Something like:

fq=IF(count(specialties:Cardiologist)>0)specialties:Cardiologist,*:*

Or more generic:

fq=IF(count(specialties:$input)>0)specialties:$input,*:*

Not sure how to do that without 2 queries into Solr.

Thank you.


On Wed, Jun 22, 2011 at 6:27 AM, lee carroll
<le...@googlemail.com> wrote:
> Hi Bill,
>
>>So that part works. Then when I output the facet, I need a different
>>behavior than the default. I need
>>The facet to only output the value that matches (scored) - NOT ALL VALUES
>>in the multiValued field.
>
>>I think it makes sense?
>
> Why do you need this ? If your use case is faceted navigation then not showing
> all the facet terms which match your query would be mis-leading to your users.
> The fact is your data indicates Ben the cardiologist is also a GP etc.
> Is it not valid for
> your users to be able to further filter on cardiologists who are also
> specialists in x other disciplines ? If the specialisms are mutually
> exclusive then your data will reflect this.
>
> The fact is x number of cardiologists match and x number of GP's match etc
>
> I may be missing the point here as you have not said why you need to do this ?
>
> cheers lee c
>
>
> On 22 June 2011 09:34, Michael Kuhlmann <so...@kuli.org> wrote:
>> Am 22.06.2011 09:49, schrieb Bill Bell:
>>> You can type q=cardiology and match on cardiologist. If stemming did not
>>> work you can just add a synonym:
>>>
>>> cardiology,cardiologist
>>
>> Okay, synonyms are the only way I can think of a realistic match.
>>
>> Stemming won't work on a facet field; you wouldn't get "Cardiologist: 3"
>> as the result but "cardiolog: 3" or something like that instead.
>>
>> Normally, you use declare facet field explicitly for facetting, and not
>> for searching, exactly because stemming and tokenizing on facet fields
>> don't make sense.
>>
>> And the short answer is: No, that's not possible.
>>
>> -Kuli
>>
>



-- 
Bill Bell
billnbell@gmail.com
cell 720-256-8076

Re: MultiValued facet behavior question

Posted by lee carroll <le...@googlemail.com>.
Hi Bill,

>So that part works. Then when I output the facet, I need a different
>behavior than the default. I need
>The facet to only output the value that matches (scored) - NOT ALL VALUES
>in the multiValued field.

>I think it makes sense?

Why do you need this ? If your use case is faceted navigation then not showing
all the facet terms which match your query would be mis-leading to your users.
The fact is your data indicates Ben the cardiologist is also a GP etc.
Is it not valid for
your users to be able to further filter on cardiologists who are also
specialists in x other disciplines ? If the specialisms are mutually
exclusive then your data will reflect this.

The fact is x number of cardiologists match and x number of GP's match etc

I may be missing the point here as you have not said why you need to do this ?

cheers lee c


On 22 June 2011 09:34, Michael Kuhlmann <so...@kuli.org> wrote:
> Am 22.06.2011 09:49, schrieb Bill Bell:
>> You can type q=cardiology and match on cardiologist. If stemming did not
>> work you can just add a synonym:
>>
>> cardiology,cardiologist
>
> Okay, synonyms are the only way I can think of a realistic match.
>
> Stemming won't work on a facet field; you wouldn't get "Cardiologist: 3"
> as the result but "cardiolog: 3" or something like that instead.
>
> Normally, you use declare facet field explicitly for facetting, and not
> for searching, exactly because stemming and tokenizing on facet fields
> don't make sense.
>
> And the short answer is: No, that's not possible.
>
> -Kuli
>

Re: MultiValued facet behavior question

Posted by Michael Kuhlmann <so...@kuli.org>.
Am 22.06.2011 09:49, schrieb Bill Bell:
> You can type q=cardiology and match on cardiologist. If stemming did not
> work you can just add a synonym:
> 
> cardiology,cardiologist

Okay, synonyms are the only way I can think of a realistic match.

Stemming won't work on a facet field; you wouldn't get "Cardiologist: 3"
as the result but "cardiolog: 3" or something like that instead.

Normally, you use declare facet field explicitly for facetting, and not
for searching, exactly because stemming and tokenizing on facet fields
don't make sense.

And the short answer is: No, that's not possible.

-Kuli

Re: MultiValued facet behavior question

Posted by Bill Bell <bi...@gmail.com>.
You can type q=cardiology and match on cardiologist. If stemming did not
work you can just add a synonym:

cardiology,cardiologist

But that is not the issue. The issue is around multiValue fields and
facets. You would expect a user
Who is searching on the multiValued field to match on some values in
there. For example,
they type "Cardiologist" and it matches on the value "Cardiologist". So it
matches "in the multiValue field".
So that part works. Then when I output the facet, I need a different
behavior than the default. I need
The facet to only output the value that matches (scored) - NOT ALL VALUES
in the multiValued field.

I think it makes sense?


On 6/22/11 1:42 AM, "Michael Kuhlmann" <so...@kuli.org> wrote:

>Am 22.06.2011 05:37, schrieb Bill Bell:
>> It can get more complicated. Here is another example:
>> 
>> q=cardiology&defType=dismax&qf=specialties
>> 
>> 
>> (Cardiology and cardiologist are stems)...
>> 
>> But I don't really know which value in Cardiologist match perfectly.
>> 
>> Again, I only want it to return:
>> 
>> Cardiologist: 3
>
>You would never get "Cardiologist: 3" as the facet result, because if
>"Cardiologist" would be in your index, it's impossible to find it when
>searching for "cardiology" (except when you manage to write some strange
>tokenizer that translates "cardiology" to "Cardiologist" on query time,
>including the upper case letter).
>
>Facets are always taken from the index, so they usually match exactly or
>never when querying for it.
>
>-Kuli



Re: MultiValued facet behavior question

Posted by Michael Kuhlmann <so...@kuli.org>.
Am 22.06.2011 05:37, schrieb Bill Bell:
> It can get more complicated. Here is another example:
> 
> q=cardiology&defType=dismax&qf=specialties
> 
> 
> (Cardiology and cardiologist are stems)...
> 
> But I don't really know which value in Cardiologist match perfectly.
> 
> Again, I only want it to return:
> 
> Cardiologist: 3

You would never get "Cardiologist: 3" as the facet result, because if
"Cardiologist" would be in your index, it's impossible to find it when
searching for "cardiology" (except when you manage to write some strange
tokenizer that translates "cardiology" to "Cardiologist" on query time,
including the upper case letter).

Facets are always taken from the index, so they usually match exactly or
never when querying for it.

-Kuli

Re: MultiValued facet behavior question

Posted by Bill Bell <bi...@gmail.com>.
Doing it with q=specialities:Cardiologist or
q=Cardiologist&defType=dismax&qf=specialties
does not matter, the issue is how I see facets. I want the facets to only
show the one match,
and not all the multiValued fields in specialties that match...

Example,

Name|specialties
Bell|Cardiologist
Smith|Cardiologist,Family Doctor
Adams,Cardiologist,Family Doctor,Internist

When I facet.field=specialties I get:

Cardiologist: 3
Internist: 1
Family Doctor: 1


I only want it to return:

Cardiologist: 3

Because this matches exactly... Facet on the field that matches and only
return the number for that.

It can get more complicated. Here is another example:

q=cardiology&defType=dismax&qf=specialties


(Cardiology and cardiologist are stems)...

But I don't really know which value in Cardiologist match perfectly.

Again, I only want it to return:

Cardiologist: 3

If I searched on q=internist&defType=dismax&qf=specialties, I want the
result to be:


Internist: 1


Does this all make sense?







On 6/21/11 8:23 PM, "Darren Govoni" <da...@ontrenet.com> wrote:

>So are you saying that for all results for "cardiologist",
>you don't want facets not matching "Cardiologist" to be
>returned as facets?
>
>what happens when you make q=specialities:Cardiologist?
>instead of just q=Cardiologist?
>
>Seems that if you make the query on the field, then all
>your results will necessarily qualify and you can discard
>any additional facets you don't want (e.g. that don't
>match the initial query term).
>
>Maybe you can write what you see now, with what you
>want to help clarify.
>
>On 06/21/2011 09:47 PM, Bill Bell wrote:
>> I have a field: specialties that is multiValued.
>>
>> It indicates the doctor's specialties: cardiologist, internist, etc.
>>
>> When someone does a search: "Cardiologist", I use
>> 
>>q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=speci
>>alt
>> ies
>>
>> What I want to come out in the facet is the Cardiologist (since it
>>matches
>> exactly) and the number that matches: 700.
>> I don't want to see the other values that are not Cardiologist.
>>
>> Now I see:
>>
>> Cardiologist: 700
>> Internist: 45
>> Family Doctor: 20
>>
>> This means that several Cardiologist's are also internists and family
>> doctors. When it matches exactly, I don't want to see Internists, Family
>> Doctors. How do I send a query to Solr with a condition.
>> Facet.query=specialties:Cardiologist&facet.field=specialties
>>
>> Then if the query returns something use it, otherwise use the field one?
>>
>> Other ideas?
>>
>>
>>
>>
>



Re: MultiValued facet behavior question

Posted by Darren Govoni <da...@ontrenet.com>.
So are you saying that for all results for "cardiologist",
you don't want facets not matching "Cardiologist" to be
returned as facets?

what happens when you make q=specialities:Cardiologist?
instead of just q=Cardiologist?

Seems that if you make the query on the field, then all
your results will necessarily qualify and you can discard
any additional facets you don't want (e.g. that don't
match the initial query term).

Maybe you can write what you see now, with what you
want to help clarify.

On 06/21/2011 09:47 PM, Bill Bell wrote:
> I have a field: specialties that is multiValued.
>
> It indicates the doctor's specialties: cardiologist, internist, etc.
>
> When someone does a search: "Cardiologist", I use
> q=cardiologist&defType=dismax&qf=specialties&facet=true&facet.field=specialt
> ies
>
> What I want to come out in the facet is the Cardiologist (since it matches
> exactly) and the number that matches: 700.
> I don't want to see the other values that are not Cardiologist.
>
> Now I see:
>
> Cardiologist: 700
> Internist: 45
> Family Doctor: 20
>
> This means that several Cardiologist's are also internists and family
> doctors. When it matches exactly, I don't want to see Internists, Family
> Doctors. How do I send a query to Solr with a condition.
> Facet.query=specialties:Cardiologist&facet.field=specialties
>
> Then if the query returns something use it, otherwise use the field one?
>
> Other ideas?
>
>
>
>