tags:

views:

168

answers:

1

Is there any way to return in the fields list whether a value exists as one of the values of a multivalued field?

E.g., if your schema is

<schema>
...
<field name="user_name" type="text" indexed="true" stored="true" required="true" />
<field name="follower" type="integer" indexed="true" stored="true" multiValued="true" />
...
</schema>

A sample document might look like:

<doc>
<field name="user_name">tester blah</field>
<field name="follower">1</field>
<field name="follower">62</field>
<field name="follower">63</field>
<field name="follower">64</field>
</doc>

I would like to be able to query for, say, "tester" and follower:62 and have it match "tester blah" and have some indication of whether 62 is a follower or not in the results.

A: 

If you query for something AND follower:62, you can be sure 62 will be a follower of any result you get :)

Now if follower:62 comes as an optional clause in a OR for instance, I guess you can use the highlighting facility to achieve your requirement.

hl.field=...,follower,..
hl.requireFieldMatch= true

You'll get something in the highlighting part of the response for your document if it matches your follower:62.

jeje