# Searching for a particular phrase in \_all fields generates less number of records comparing to do the same thing on small number of fields

**URL:** <https://discuss.elastic.co/t/searching-for-a-particular-phrase-in-all-fields-generates-less-number-of-records-comparing-to-do-the-same-thing-on-small-number-of-fields/103578>\
**Category:** Elasticsearch\
**Created:** [October 11, 2017, 3:56pm UTC](https://discuss.elastic.co/t/searching-for-a-particular-phrase-in-all-fields-generates-less-number-of-records-comparing-to-do-the-same-thing-on-small-number-of-fields/103578 "2017-10-11T15:56:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nina\_s](https://avatars.discourse-cdn.com/v4/letter/n/7ea924/32.png) [@Nina\_s](https://discuss.elastic.co/u/Nina_s)\
**Post date:** [October 11, 2017, 3:56pm UTC](https://discuss.elastic.co/t/searching-for-a-particular-phrase-in-all-fields-generates-less-number-of-records-comparing-to-do-the-same-thing-on-small-number-of-fields/103578/1 "2017-10-11T15:56:25Z")

</div>

Hi,  
I wanted to search for a particular phrase using elasticsearch on both \_all fields and only 2 fields. The phrase is taken from a file listing more than 10000 keywords.: Here is the code:  
from elasticsearch import Elasticsearch  
import os, sys  
import requests  
import json  
es = Elasticsearch(['localhost:9200/'])  
with open('localDrive\extract\_keywords\t2.txt') as my\_keywordfile:  
for keyword in my\_keywordfile.readlines():  
keyword\_array.append(keyword.strip().strip("'"))  
with open('LocalFile\_description\_Results2.txt','w',encoding="utf-8") as f:  
for x in keyword\_array:  
doc = {  
"query": {  
"multi\_match": {  
"query": x,  
"type": "phrase",  
"fields":["title", "description"],  
}  
res = es.search(index='xxx\_062617', body=doc)  
json.dump(res, f, ensure\_ascii=False)  
f.write(("\n"))

```
f.close()

```

Also, the query that matches \_all fields is:

```
"multi_match": {
                                    "query": x,
                                     "type": "phrase",
                                     "fields":"_all",   
                                 }

```

Also, here is what I have for mapping .....  
"`dataset": { "properties": { "creators": { "type": "string" }, "title": { "type": "string" }, "description": { "type": "string" }, "types": { "type": "string", "fields":{ "raw":{"type":"string","index":"not_analyzed"} } },`  
Now what happens is that, I get 101 returned record if I use query only on title, and description. But, I only get 100 returned records if I use \_all fields. And if I want to get unique IDs by combining the ids of all records and remove duplicate ones, I see that there are only 86 duplicate records!

My questions are: 1- Does using type:phrase works differently if I use \_all fields? 2- Should not I get more number of records if I use \_all fields? 3- If \_all includes all fields including title, and description, then why using \_all does not cover all the records that have been returned by quering title, and description?

Thanks,

---

<div class="post-metadata">

**Author:** ![Nina\_s](https://avatars.discourse-cdn.com/v4/letter/n/7ea924/32.png) [@Nina\_s](https://discuss.elastic.co/u/Nina_s)\
**Post date:** [October 21, 2017, 6:22pm UTC](https://discuss.elastic.co/t/searching-for-a-particular-phrase-in-all-fields-generates-less-number-of-records-comparing-to-do-the-same-thing-on-small-number-of-fields/103578/2 "2017-10-21T18:22:21Z")

</div>

Hi everyone!  
I found out the issue! The issue was that i did not use size as a parameter, so, basically it was showing only 10 hits and when I removed duplicated \_ids from the retrieved records, the number of unique records from \_all was less than the other one. When I used size and assigned it to 10000, the problem solved!

---

<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:** [November 18, 2017, 6:22pm UTC](https://discuss.elastic.co/t/searching-for-a-particular-phrase-in-all-fields-generates-less-number-of-records-comparing-to-do-the-same-thing-on-small-number-of-fields/103578/3 "2017-11-18T18:22:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
