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 sara hajili <ha...@gmail.com> on 2015/09/12 09:49:11 UTC

search on multiValued field

hi
 in my schema i have a tag field.
this field set multiValued="true".
now my question is about search on multivalued field.
if i add thid doc to sor:
{
id:1,
tag:{"tag1","tag2"}
},

{
id:2,
tag:{"tag1","tag2"}
},

when i search on q="tag1"
i get just :
{
id:1,
tag:{"tag1","tag2"}
},

but if i add docs in this way:
{
id:1,
tag:"tag1",
tag:"tag2"
},
{
id:2,
tag:"tag1",
tag:"tag2"
},
now if i search to q="tag1"
i get both of docs as a result.
i'm confused.!what is difference between 2 docs?
and can i search on this doc ?
{
id:1,
tag:{"tag1","tag2"}
},
and get correct result(correct result is getting 2 doc all together)
tnx.

Re: search on multiValued field

Posted by Upayavira <uv...@odoko.co.uk>.
Your "correct" doc isn't valid json. Try tag:["tag1", "tag2"] which
would be valid.

Upayavira

On Sat, Sep 12, 2015, at 08:49 AM, sara hajili wrote:
> hi
>  in my schema i have a tag field.
> this field set multiValued="true".
> now my question is about search on multivalued field.
> if i add thid doc to sor:
> {
> id:1,
> tag:{"tag1","tag2"}
> },
> 
> {
> id:2,
> tag:{"tag1","tag2"}
> },
> 
> when i search on q="tag1"
> i get just :
> {
> id:1,
> tag:{"tag1","tag2"}
> },
> 
> but if i add docs in this way:
> {
> id:1,
> tag:"tag1",
> tag:"tag2"
> },
> {
> id:2,
> tag:"tag1",
> tag:"tag2"
> },
> now if i search to q="tag1"
> i get both of docs as a result.
> i'm confused.!what is difference between 2 docs?
> and can i search on this doc ?
> {
> id:1,
> tag:{"tag1","tag2"}
> },
> and get correct result(correct result is getting 2 doc all together)
> tnx.