# Different results querying the same field

**URL:** <https://discuss.elastic.co/t/different-results-querying-the-same-field/9848>\
**Category:** Elasticsearch\
**Created:** [November 27, 2012, 6:13pm UTC](https://discuss.elastic.co/t/different-results-querying-the-same-field/9848 "2012-11-27T18:13:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinicius\_Carvalho](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinicius_carvalho/32/770_2.png) [@Vinicius\_Carvalho](https://discuss.elastic.co/u/Vinicius_Carvalho)\
**Post date:** [November 27, 2012, 6:13pm UTC](https://discuss.elastic.co/t/different-results-querying-the-same-field/9848/1 "2012-11-27T18:13:16Z")

</div>

Hello there! We are trying to tune our ES to get more relevant results, I'm  
reading through all the lucene scoring process, and a few things I've  
noticed and I kinda get it:

Our \_all field is composed of three fields (artistName, albumName, songName)

When we search for something like:

{  
"query": {  
"query\_string": {  
"query": "bad religion"  
}  
}  
}

versus

{  
"explain": true,  
"query": {  
"query\_string": {  
"query": "bad religion",  
"fields" : ["songName","artistName","albumName"]  
}  
}  
}

We get very different results. The all field has much more relevant stuff.  
I would assume that the termNorms and idfs are better in one field  
containing everything versus multiple fields. I'm a bit worried that we  
have such different results, but in the end if we have to use the \_all I  
don't mind.

Now this is a bit worrisome:

{  
"explain": true,  
"query": {  
"query\_string": {  
"query": "bad religion"  
}  
}  
}

vs

{  
"explain": true,  
"query": {  
"query\_string": {  
"query": "bad religion",  
"fields" : ["\_all"]  
}  
}  
}

return different results. To prove I'm pasting the explain of both queries  
bellow. They are pretty much the same, but they differ in termFreq (aren't  
we searching in the exact field for both?), and the results are impacted on  
that as well, I'm getting different albums from bad religion depending on  
the query I'm using.

Is this expected?

Regards

{  
value: 7.253157  
description: sum of:  
details: [  
{  
value: 2.589271  
description: weight(\_all:bad in 1093577), product of:  
details: [  
{  
value: 0.5974825  
description: queryWeight(\_all:bad), product of:  
details: [  
{  
value: 6.933816  
description: idf(docFreq=14942, maxDocs=5642368)  
}  
{  
value: 0.08616936  
description: queryNorm  
}  
]  
}  
{  
value: 4.333635  
description: fieldWeight(\_all:bad in 1093577), product of:  
details: [  
{  
value: 1  
description: tf(termFreq(\_all:bad)=1)  
}  
{  
value: 6.933816  
description: idf(docFreq=14942, maxDocs=5642368)  
}  
{  
value: 0.625  
description: fieldNorm(field=\_all, doc=1093577)  
}  
]  
}  
]  
}  
{  
value: 4.663886  
description: weight(\_all:religion in 1093577), product of:  
details: [  
{  
value: 0.80188185  
description: queryWeight(\_all:religion), product of:  
details: [  
{  
value: 9.3058815  
description: idf(docFreq=1393, maxDocs=5642368)  
}  
{  
value: 0.08616936  
description: queryNorm  
}  
]  
}  
{  
value: 5.816176  
description: fieldWeight(\_all:religion in 1093577), product of:  
details: [  
{  
value: 1  
description: tf(termFreq(\_all:religion)=1)  
}  
{  
value: 9.3058815  
description: idf(docFreq=1393, maxDocs=5642368)  
}  
{  
value: 0.625  
description: fieldNorm(field=\_all, doc=1093577)  
}  
]  
}  
]  
}  
]  
}  
}

===============================================

{  
value: 7.190833  
description: sum of:  
details: [  
{  
value: 2.5919292  
description: weight(\_all:bad in 890369), product of:  
details: [  
{  
value: 0.6003741  
description: queryWeight(\_all:bad), product of:  
details: [  
{  
value: 6.907504  
description: idf(docFreq=18253, maxDocs=6713585)  
}  
{  
value: 0.086916216  
description: queryNorm  
}  
]  
}  
{  
value: 4.31719  
description: fieldWeight(\_all:bad in 890369), product of:  
details: [  
{  
value: 1  
description: tf(termFreq(\_all:bad)=1)  
}  
{  
value: 6.907504  
description: idf(docFreq=18253, maxDocs=6713585)  
}  
{  
value: 0.625  
description: fieldNorm(field=\_all, doc=890369)  
}  
]  
}  
]  
}  
{  
value: 4.5989037  
description: weight(\_all:religion in 890369), product of:  
details: [  
{  
value: 0.7997193  
description: queryWeight(\_all:religion), product of:  
details: [  
{  
value: 9.201036  
description: idf(docFreq=1841, maxDocs=6713585)  
}  
{  
value: 0.086916216  
description: queryNorm  
}  
]  
}  
{  
value: 5.7506475  
description: fieldWeight(\_all:religion in 890369), product of:  
details: [  
{  
value: 1  
description: tf(termFreq(\_all:religion)=1)  
}  
{  
value: 9.201036  
description: idf(docFreq=1841, maxDocs=6713585)  
}  
{  
value: 0.625  
description: fieldNorm(field=\_all, doc=890369)  
}  
]  
}  
]  
}  
]  
}  
}

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [November 28, 2012, 11:35pm UTC](https://discuss.elastic.co/t/different-results-querying-the-same-field/9848/2 "2012-11-28T23:35:38Z")

</div>

These queries should be the same. Judging from the explain output, it looks  
like these two queries are searching two different sets of documents. Did  
you continue indexing while running these searches? If not, could you  
repeat the test by running the first query several times to make sure that  
it returns the same result every time? Could you create a repro for this  
issue?

On Tuesday, November 27, 2012 1:13:16 PM UTC-5, Vinicius Carvalho wrote:

> Hello there! We are trying to tune our ES to get more relevant results,  
> I'm reading through all the lucene scoring process, and a few things I've  
> noticed and I kinda get it:
> 
> Our \_all field is composed of three fields (artistName, albumName,  
> songName)
> 
> When we search for something like:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": "bad religion"  
> }  
> }  
> }
> 
> versus
> 
> {  
> "explain": true,  
> "query": {  
> "query\_string": {  
> "query": "bad religion",  
> "fields" : ["songName","artistName","albumName"]  
> }  
> }  
> }
> 
> We get very different results. The all field has much more relevant stuff.  
> I would assume that the termNorms and idfs are better in one field  
> containing everything versus multiple fields. I'm a bit worried that we  
> have such different results, but in the end if we have to use the \_all I  
> don't mind.
> 
> Now this is a bit worrisome:
> 
> {  
> "explain": true,  
> "query": {  
> "query\_string": {  
> "query": "bad religion"  
> }  
> }  
> }
> 
> vs
> 
> {  
> "explain": true,  
> "query": {  
> "query\_string": {  
> "query": "bad religion",  
> "fields" : ["\_all"]  
> }  
> }  
> }
> 
> return different results. To prove I'm pasting the explain of both queries  
> bellow. They are pretty much the same, but they differ in termFreq (aren't  
> we searching in the exact field for both?), and the results are impacted on  
> that as well, I'm getting different albums from bad religion depending on  
> the query I'm using.
> 
> Is this expected?
> 
> Regards
> 
> {  
> value: 7.253157  
> description: sum of:  
> details: [  
> {  
> value: 2.589271  
> description: weight(\_all:bad in 1093577), product of:  
> details: [  
> {  
> value: 0.5974825  
> description: queryWeight(\_all:bad), product of:  
> details: [  
> {  
> value: 6.933816  
> description: idf(docFreq=14942, maxDocs=5642368)  
> }  
> {  
> value: 0.08616936  
> description: queryNorm  
> }  
> ]  
> }  
> {  
> value: 4.333635  
> description: fieldWeight(\_all:bad in 1093577), product of:  
> details: [  
> {  
> value: 1  
> description: tf(termFreq(\_all:bad)=1)  
> }  
> {  
> value: 6.933816  
> description: idf(docFreq=14942, maxDocs=5642368)  
> }  
> {  
> value: 0.625  
> description: fieldNorm(field=\_all, doc=1093577)  
> }  
> ]  
> }  
> ]  
> }  
> {  
> value: 4.663886  
> description: weight(\_all:religion in 1093577), product of:  
> details: [  
> {  
> value: 0.80188185  
> description: queryWeight(\_all:religion), product of:  
> details: [  
> {  
> value: 9.3058815  
> description: idf(docFreq=1393, maxDocs=5642368)  
> }  
> {  
> value: 0.08616936  
> description: queryNorm  
> }  
> ]  
> }  
> {  
> value: 5.816176  
> description: fieldWeight(\_all:religion in 1093577), product of:  
> details: [  
> {  
> value: 1  
> description: tf(termFreq(\_all:religion)=1)  
> }  
> {  
> value: 9.3058815  
> description: idf(docFreq=1393, maxDocs=5642368)  
> }  
> {  
> value: 0.625  
> description: fieldNorm(field=\_all, doc=1093577)  
> }  
> ]  
> }  
> ]  
> }  
> ]  
> }  
> }
> 
> ===============================================
> 
> {  
> value: 7.190833  
> description: sum of:  
> details: [  
> {  
> value: 2.5919292  
> description: weight(\_all:bad in 890369), product of:  
> details: [  
> {  
> value: 0.6003741  
> description: queryWeight(\_all:bad), product of:  
> details: [  
> {  
> value: 6.907504  
> description: idf(docFreq=18253, maxDocs=6713585)  
> }  
> {  
> value: 0.086916216  
> description: queryNorm  
> }  
> ]  
> }  
> {  
> value: 4.31719  
> description: fieldWeight(\_all:bad in 890369), product of:  
> details: [  
> {  
> value: 1  
> description: tf(termFreq(\_all:bad)=1)  
> }  
> {  
> value: 6.907504  
> description: idf(docFreq=18253, maxDocs=6713585)  
> }  
> {  
> value: 0.625  
> description: fieldNorm(field=\_all, doc=890369)  
> }  
> ]  
> }  
> ]  
> }  
> {  
> value: 4.5989037  
> description: weight(\_all:religion in 890369), product of:  
> details: [  
> {  
> value: 0.7997193  
> description: queryWeight(\_all:religion), product of:  
> details: [  
> {  
> value: 9.201036  
> description: idf(docFreq=1841, maxDocs=6713585)  
> }  
> {  
> value: 0.086916216  
> description: queryNorm  
> }  
> ]  
> }  
> {  
> value: 5.7506475  
> description: fieldWeight(\_all:religion in 890369), product of:  
> details: [  
> {  
> value: 1  
> description: tf(termFreq(\_all:religion)=1)  
> }  
> {  
> value: 9.201036  
> description: idf(docFreq=1841, maxDocs=6713585)  
> }  
> {  
> value: 0.625  
> description: fieldNorm(field=\_all, doc=890369)  
> }  
> ]  
> }  
> ]  
> }  
> ]  
> }  
> }

--

---

<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, 3:02am UTC](https://discuss.elastic.co/t/different-results-querying-the-same-field/9848/3 "2017-07-06T03:02:20Z")

</div>


