# Query on arrays

**URL:** <https://discuss.elastic.co/t/query-on-arrays/18345>\
**Category:** Elasticsearch\
**Created:** [June 26, 2014, 2:29am UTC](https://discuss.elastic.co/t/query-on-arrays/18345 "2014-06-26T02:29:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shane](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@shane](https://discuss.elastic.co/u/shane)\
**Post date:** [June 26, 2014, 2:29am UTC](https://discuss.elastic.co/t/query-on-arrays/18345/1 "2014-06-26T02:29:26Z")

</div>

I've got some indexed documents with some data that looks like this:

```
    "_source":{
           "title":"The Fault in Our Stars",
           "contributors":{
              "name":"John Green",
           }

```

}

Then I've got other documents with multiple contributors:

```
        "_source":{
           "title":"Horror for Good: A Charitable Anthology",
           "contributors":{
              "name":[
                 "Joe R Lansdale",
                 "Ray Garton",
                 "F. Paul Wilson",
                 "Ian Harding",
                 "Shaun Hutson",
                 "Jeff Strand",
                 "Jack Ketchum",
                 "Wrath James White",
                 "Monica J. O'Rourke",
                 "Lisa Morton",
                 "Laird Barron",
                 "Joe McKinney",
                 "Richard Salter",
                 "Thomas Lee",
                 "Gary McMahon",
                 "Taylor Grant",
                 "Lorne Dixon",
                 "Nate Southard",
                 "Tracie McBride",
                 "Robert S Wilson",
                 "John Mantooth",
                 "G.N. Braun",
                 "John F D Taff",
                 "Benjamin Kane Ethridge",
                 "Stephen Bacon",
                 "Steven W Booth",
                 "Brad C. Hodson",
                 "Jonathon Templar",
                 "Mark Scioneaux",
                 "R.J. Cavender",
                 "Norman L. Rubenstein",
                 "Danica Green",
                 "G.R. Yeates",
                 "Boyd E. Harris",
                 "Rena Mason"
              ],

           }

```

(This is simplified data, but I've included the relevant parts.)

The issue is when I do a multi match query on contributors.name. Take the  
query "john green" as an example: I always get higher scoring for documents  
like the second one, even though "john" and "green" aren't at all close to  
each other.

If I do a multi match query with type=phrase that helps, but a document  
with John Green as one of several authors always comes up at the top of the  
list, beating out any document with John Green as the only author, and I  
have custom scoring in place that should cause another particular document  
to score higher. Also, I don't want to do phrase matching because I want to  
be able to do a cross\_fields query across title and contributor.name, so  
that queries like "the fault in our stars john green" work.

So why are arrays with many values preferred over the single value in this  
case? And how can I index or query this data to avoid this problem?

This is on ES 1.1.1.

Thanks,

Shane

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/04ac28f7-ee0f-4b8c-996b-f048fb4dd576%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/04ac28f7-ee0f-4b8c-996b-f048fb4dd576%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![shane](https://avatars.discourse-cdn.com/v4/letter/s/dbc845/32.png) [@shane](https://discuss.elastic.co/u/shane)\
**Post date:** [June 26, 2014, 2:30am UTC](https://discuss.elastic.co/t/query-on-arrays/18345/2 "2014-06-26T02:30:49Z")

</div>

I should also note that the custom scoring is not the problem: it exhibits  
a preference for documents with many values for contributor.name even when  
the custom scoring is removed.

On Wednesday, June 25, 2014 7:29:26 PM UTC-7, shane wrote:

> I've got some indexed documents with some data that looks like this:
> 
> ```
> "_source":{
> "title":"The Fault in Our Stars",
> "contributors":{
> "name":"John Green",
> }
> 
> ```
> 
> }
> 
> Then I've got other documents with multiple contributors:
> 
> ```
> "_source":{
> "title":"Horror for Good: A Charitable Anthology",
> "contributors":{
> "name":[
> "Joe R Lansdale",
> "Ray Garton",
> "F. Paul Wilson",
> "Ian Harding",
> "Shaun Hutson",
> "Jeff Strand",
> "Jack Ketchum",
> "Wrath James White",
> "Monica J. O'Rourke",
> "Lisa Morton",
> "Laird Barron",
> "Joe McKinney",
> "Richard Salter",
> "Thomas Lee",
> "Gary McMahon",
> "Taylor Grant",
> "Lorne Dixon",
> "Nate Southard",
> "Tracie McBride",
> "Robert S Wilson",
> "John Mantooth",
> "G.N. Braun",
> "John F D Taff",
> "Benjamin Kane Ethridge",
> "Stephen Bacon",
> "Steven W Booth",
> "Brad C. Hodson",
> "Jonathon Templar",
> "Mark Scioneaux",
> "R.J. Cavender",
> "Norman L. Rubenstein",
> "Danica Green",
> "G.R. Yeates",
> "Boyd E. Harris",
> "Rena Mason"
> ],
> 
> }
> 
> ```
> 
> (This is simplified data, but I've included the relevant parts.)
> 
> The issue is when I do a multi match query on contributors.name. Take the  
> query "john green" as an example: I always get higher scoring for documents  
> like the second one, even though "john" and "green" aren't at all close to  
> each other.
> 
> If I do a multi match query with type=phrase that helps, but a document  
> with John Green as one of several authors always comes up at the top of the  
> list, beating out any document with John Green as the only author, and I  
> have custom scoring in place that should cause another particular document  
> to score higher. Also, I don't want to do phrase matching because I want to  
> be able to do a cross\_fields query across title and contributor.name, so  
> that queries like "the fault in our stars john green" work.
> 
> So why are arrays with many values preferred over the single value in this  
> case? And how can I index or query this data to avoid this problem?
> 
> This is on ES 1.1.1.
> 
> Thanks,
> 
> Shane

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8b4fd820-af8b-42df-ac2d-81ac5a51e7af%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8b4fd820-af8b-42df-ac2d-81ac5a51e7af%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:19am UTC](https://discuss.elastic.co/t/query-on-arrays/18345/3 "2017-07-06T01:19:37Z")

</div>


