# Phrase query, using shingles(index\_phrases) results in inconsistent results with the default query method

**URL:** https://discuss.elastic.co/t/phrase-query-using-shingles-index-phrases-results-in-inconsistent-results-with-the-default-query-method/382625
**Category:** Elasticsearch
**Created:** [October 13, 2025, 8:26am UTC](https://discuss.elastic.co/t/phrase-query-using-shingles-index-phrases-results-in-inconsistent-results-with-the-default-query-method/382625 "2025-10-13T08:26:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fangqingsong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fangqingsong/32/50588_2.png) [@fangqingsong](https://discuss.elastic.co/u/fangqingsong)
#### Post date: [October 13, 2025, 8:26am UTC](https://discuss.elastic.co/t/phrase-query-using-shingles-index-phrases-results-in-inconsistent-results-with-the-default-query-method/382625/1 "2025-10-13T08:26:34Z")

</div>

ES 9.1.3, geonames datasets, index name is “field-name-index-phrase-geonames”

```auto
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size dataset.size
green open field-name-index-phrase-geonames wWbyhMZwQeOeyV2Lvjy8Ng 3 0 11396503 0 2.5gb 2.5gb 2.5gb

```

curl -XGET "[http://localhost:9200/field-name-index-phrase-geonames/\_search](http://localhost:9200/field-name-index-phrase-geonames/_search)" -H 'Content-Type: application/json' -d'  
{  
"size": 2,  
"track\_total\_hits": true,  
"profile": true,  
"query": {  
"match\_phrase": {  
"name": "hall of jehovahs"  
}  
}  
}'

field “name” mappings like:

```json
{
    "field-name-index-phrase-geonames": {
        "mappings": {
            "name": {
                "full_name": "name",
                "mapping": {
                    "name": {
                        "type": "text",
                        "fields": {
                            "raw": {
                                "type": "text",
                                "analyzer": "standard"
                            }
                        },
                        "analyzer": "standard",
                        "index_phrases": true
                    }
                }
            }
        }
    }
}

```

default match\_phrase result is:

```json
{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 3,
        "successful": 3,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 1033,
            "relation": "eq"
        },
        "max_score": 12.395212,
        "hits": [
            {
                "_index": "field-name-index-phrase-geonames",
                "_id": "ktLihJkB4j3NtqEkX57g",
                "_score": 12.395212,
                "_source": {
                    "geonameid": 5280410,
                    "name": "Kingdom Hall of Jehovahs Witnesses",
                    "asciiname": "Kingdom Hall of Jehovahs Witnesses",
                    "feature_class": "S",
                    "feature_code": "CH",
                    "country_code": "US",
                    "admin1_code": "WV",
                    "admin2_code": "029",
                    "population": 0,
                    "elevation": 237,
                    "dem": "235",
                    "timezone": "America/New_York",
                    "location": [
                        -80.58424,
                        40.40618
                    ]
                }
            },
            {
                "_index": "field-name-index-phrase-geonames",
                "_id": "fB7ihJkB4j3NtqEkr2r8",
                "_score": 12.395212,
                "_source": {
                    "geonameid": 6335206,
                    "name": "Kingdom Hall of Jehovahs Witnesses",
                    "asciiname": "Kingdom Hall of Jehovahs Witnesses",
                    "feature_class": "S",
                    "feature_code": "CH",
                    "country_code": "US",
                    "admin1_code": "NY",
                    "admin2_code": "071",
                    "population": 0,
                    "elevation": 80,
                    "dem": "85",
                    "timezone": "America/New_York",
                    "location": [
                        -74.03778,
                        41.50917
                    ]
                }
            }
        ]
    },
    "profile": {
        "shards": [
            {
                "id": "[eMTQVBxNRHSgXOlKr-wicw][field-name-index-phrase-geonames][0]",
                "node_id": "eMTQVBxNRHSgXOlKr-wicw",
                "shard_id": 0,
                "index": "field-name-index-phrase-geonames",
                "cluster": "(local)",
                "searches": [
                    {
                        "query": [
                            {
                                "type": "PhraseQuery",
                                "description": "name:\"hall of jehovahs\"",
                                "time_in_nanos": 831416,
                                "breakdown": {
                                    "set_min_competitive_score_count": 0,
                                    "match_count": 344,
                                    "shallow_advance_count": 0,
                                    "set_min_competitive_score": 0,
                                    "next_doc": 212406,
                                    "match": 148057,
                                    "next_doc_count": 351,
                                    "score_count": 344,
                                    "compute_max_score_count": 0,
                                    "compute_max_score": 0,
                                    "advance": 0,
                                    "advance_count": 0,
                                    "count_weight_count": 0,
                                    "score": 65117,
                                    "build_scorer_count": 17,
                                    "create_weight": 254116,
                                    "shallow_advance": 0,
                                    "count_weight": 0,
                                    "create_weight_count": 1,
                                    "build_scorer": 151720
                                }
                            }
                        ],
                        "rewrite_time": 8479,
                        "collector": [
                            {
                                "name": "QueryPhaseCollector",
                                "reason": "search_query_phase",
                                "time_in_nanos": 192624,
                                "children": [
                                    {
                                        "name": "TopScoreDocCollector",
                                        "reason": "search_top_hits",
                                        "time_in_nanos": 164083
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "aggregations": [

                ],
                "fetch": {
                    "type": "fetch",
                    "description": "",
                    "time_in_nanos": 161875,
                    "breakdown": {
                        "load_stored_fields": 78132,
                        "load_source": 210,
                        "load_stored_fields_count": 2,
                        "next_reader_count": 1,
                        "load_source_count": 2,
                        "next_reader": 11589
                    },
                    "debug": {
                        "stored_fields": [
                            "_id",
                            "_routing",
                            "_source"
                        ]
                    },
                    "children": [
                        {
                            "type": "FetchFieldsPhase",
                            "description": "",
                            "time_in_nanos": 6730,
                            "breakdown": {
                                "process_count": 2,
                                "process": 2470,
                                "next_reader": 4260,
                                "next_reader_count": 1
                            }
                        },
                        {
                            "type": "FetchSourcePhase",
                            "description": "",
                            "time_in_nanos": 1610,
                            "breakdown": {
                                "process_count": 2,
                                "process": 1440,
                                "next_reader": 170,
                                "next_reader_count": 1
                            },
                            "debug": {
                                "fast_path": 2
                            }
                        },
                        {
                            "type": "StoredFieldsPhase",
                            "description": "",
                            "time_in_nanos": 730,
                            "breakdown": {
                                "process_count": 2,
                                "process": 360,
                                "next_reader": 370,
                                "next_reader_count": 1
                            }
                        }
                    ]
                }
            },
            {
                "id": "[eMTQVBxNRHSgXOlKr-wicw][field-name-index-phrase-geonames][1]",
                "node_id": "eMTQVBxNRHSgXOlKr-wicw",
                "shard_id": 1,
                "index": "field-name-index-phrase-geonames",
                "cluster": "(local)",
                "searches": [
                    {
                        "query": [
                            {
                                "type": "PhraseQuery",
                                "description": "name:\"hall of jehovahs\"",
                                "time_in_nanos": 949434,
                                "breakdown": {
                                    "set_min_competitive_score_count": 0,
                                    "match_count": 332,
                                    "shallow_advance_count": 0,
                                    "set_min_competitive_score": 0,
                                    "next_doc": 261512,
                                    "match": 163762,
                                    "next_doc_count": 340,
                                    "score_count": 332,
                                    "compute_max_score_count": 0,
                                    "compute_max_score": 0,
                                    "advance": 0,
                                    "advance_count": 0,
                                    "count_weight_count": 0,
                                    "score": 76974,
                                    "build_scorer_count": 18,
                                    "create_weight": 259805,
                                    "shallow_advance": 0,
                                    "count_weight": 0,
                                    "create_weight_count": 1,
                                    "build_scorer": 187381
                                }
                            }
                        ],
                        "rewrite_time": 17109,
                        "collector": [
                            {
                                "name": "QueryPhaseCollector",
                                "reason": "search_query_phase",
                                "time_in_nanos": 232327,
                                "children": [
                                    {
                                        "name": "TopScoreDocCollector",
                                        "reason": "search_top_hits",
                                        "time_in_nanos": 198590
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "aggregations": [

                ]
            },
            {
                "id": "[eMTQVBxNRHSgXOlKr-wicw][field-name-index-phrase-geonames][2]",
                "node_id": "eMTQVBxNRHSgXOlKr-wicw",
                "shard_id": 2,
                "index": "field-name-index-phrase-geonames",
                "cluster": "(local)",
                "searches": [
                    {
                        "query": [
                            {
                                "type": "PhraseQuery",
                                "description": "name:\"hall of jehovahs\"",
                                "time_in_nanos": 875061,
                                "breakdown": {
                                    "set_min_competitive_score_count": 0,
                                    "match_count": 357,
                                    "shallow_advance_count": 0,
                                    "set_min_competitive_score": 0,
                                    "next_doc": 217389,
                                    "match": 158504,
                                    "next_doc_count": 365,
                                    "score_count": 357,
                                    "compute_max_score_count": 0,
                                    "compute_max_score": 0,
                                    "advance": 0,
                                    "advance_count": 0,
                                    "count_weight_count": 0,
                                    "score": 80376,
                                    "build_scorer_count": 18,
                                    "create_weight": 267914,
                                    "shallow_advance": 0,
                                    "count_weight": 0,
                                    "create_weight_count": 1,
                                    "build_scorer": 150878
                                }
                            }
                        ],
                        "rewrite_time": 1900,
                        "collector": [
                            {
                                "name": "QueryPhaseCollector",
                                "reason": "search_query_phase",
                                "time_in_nanos": 215729,
                                "children": [
                                    {
                                        "name": "TopScoreDocCollector",
                                        "reason": "search_top_hits",
                                        "time_in_nanos": 187263
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "aggregations": [

                ]
            }
        ]
    }
}

```

using shingles result is:

```json
{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 3,
        "successful": 3,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 1033,
            "relation": "eq"
        },
        "max_score": 11.053446,
        "hits": [
            {
                "_index": "field-name-index-phrase-geonames",
                "_id": "Ev3ihJkB4j3NtqEklEKY",
                "_score": 11.053446,
                "_source": {
                    "geonameid": 4242282,
                    "name": "Kingdom Hall of Jehovahs Witnesses",
                    "asciiname": "Kingdom Hall of Jehovahs Witnesses",
                    "feature_class": "S",
                    "feature_code": "CH",
                    "country_code": "US",
                    "admin1_code": "IL",
                    "admin2_code": "083",
                    "population": 0,
                    "elevation": 192,
                    "dem": "194",
                    "timezone": "America/Chicago",
                    "location": [
                        -90.31317,
                        39.12171
                    ]
                }
            },
            {
                "_index": "field-name-index-phrase-geonames",
                "_id": "Ff3ihJkB4j3NtqEklEKY",
                "_score": 11.053446,
                "_source": {
                    "geonameid": 4242285,
                    "name": "Kingdom Hall of Jehovahs Witnesses",
                    "asciiname": "Kingdom Hall of Jehovahs Witnesses",
                    "feature_class": "S",
                    "feature_code": "CH",
                    "country_code": "US",
                    "admin1_code": "IL",
                    "admin2_code": "193",
                    "population": 0,
                    "elevation": 114,
                    "dem": "116",
                    "timezone": "America/Chicago",
                    "location": [
                        -88.15504,
                        38.09532
                    ]
                }
            }
        ]
    },
    "profile": {
        "shards": [
            {
                "id": "[eMTQVBxNRHSgXOlKr-wicw][field-name-index-phrase-geonames][0]",
                "node_id": "eMTQVBxNRHSgXOlKr-wicw",
                "shard_id": 0,
                "index": "field-name-index-phrase-geonames",
                "cluster": "(local)",
                "searches": [
                    {
                        "query": [
                            {
                                "type": "PhraseQuery",
                                "description": "name._index_phrase:\"hall of of jehovahs\"",
                                "time_in_nanos": 448858,
                                "breakdown": {
                                    "set_min_competitive_score_count": 0,
                                    "match_count": 344,
                                    "shallow_advance_count": 0,
                                    "set_min_competitive_score": 0,
                                    "next_doc": 65818,
                                    "match": 110036,
                                    "next_doc_count": 351,
                                    "score_count": 344,
                                    "compute_max_score_count": 0,
                                    "compute_max_score": 0,
                                    "advance": 0,
                                    "advance_count": 0,
                                    "count_weight_count": 0,
                                    "score": 45188,
                                    "build_scorer_count": 17,
                                    "create_weight": 173293,
                                    "shallow_advance": 0,
                                    "count_weight": 0,
                                    "create_weight_count": 1,
                                    "build_scorer": 54523
                                }
                            }
                        ],
                        "rewrite_time": 1979,
                        "collector": [
                            {
                                "name": "QueryPhaseCollector",
                                "reason": "search_query_phase",
                                "time_in_nanos": 165088,
                                "children": [
                                    {
                                        "name": "TopScoreDocCollector",
                                        "reason": "search_top_hits",
                                        "time_in_nanos": 138257
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "aggregations": [

                ]
            },
            {
                "id": "[eMTQVBxNRHSgXOlKr-wicw][field-name-index-phrase-geonames][1]",
                "node_id": "eMTQVBxNRHSgXOlKr-wicw",
                "shard_id": 1,
                "index": "field-name-index-phrase-geonames",
                "cluster": "(local)",
                "searches": [
                    {
                        "query": [
                            {
                                "type": "PhraseQuery",
                                "description": "name._index_phrase:\"hall of of jehovahs\"",
                                "time_in_nanos": 462343,
                                "breakdown": {
                                    "set_min_competitive_score_count": 0,
                                    "match_count": 332,
                                    "shallow_advance_count": 0,
                                    "set_min_competitive_score": 0,
                                    "next_doc": 74197,
                                    "match": 105639,
                                    "next_doc_count": 340,
                                    "score_count": 332,
                                    "compute_max_score_count": 0,
                                    "compute_max_score": 0,
                                    "advance": 0,
                                    "advance_count": 0,
                                    "count_weight_count": 0,
                                    "score": 39970,
                                    "build_scorer_count": 18,
                                    "create_weight": 176054,
                                    "shallow_advance": 0,
                                    "count_weight": 0,
                                    "create_weight_count": 1,
                                    "build_scorer": 66483
                                }
                            }
                        ],
                        "rewrite_time": 1860,
                        "collector": [
                            {
                                "name": "QueryPhaseCollector",
                                "reason": "search_query_phase",
                                "time_in_nanos": 176917,
                                "children": [
                                    {
                                        "name": "TopScoreDocCollector",
                                        "reason": "search_top_hits",
                                        "time_in_nanos": 147340
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "aggregations": [

                ],
                "fetch": {
                    "type": "fetch",
                    "description": "",
                    "time_in_nanos": 139597,
                    "breakdown": {
                        "load_stored_fields": 85242,
                        "load_source": 369,
                        "load_stored_fields_count": 2,
                        "next_reader_count": 1,
                        "load_source_count": 2,
                        "next_reader": 10909
                    },
                    "debug": {
                        "stored_fields": [
                            "_id",
                            "_routing",
                            "_source"
                        ]
                    },
                    "children": [
                        {
                            "type": "FetchFieldsPhase",
                            "description": "",
                            "time_in_nanos": 6760,
                            "breakdown": {
                                "process_count": 2,
                                "process": 2650,
                                "next_reader": 4110,
                                "next_reader_count": 1
                            }
                        },
                        {
                            "type": "FetchSourcePhase",
                            "description": "",
                            "time_in_nanos": 1440,
                            "breakdown": {
                                "process_count": 2,
                                "process": 1270,
                                "next_reader": 170,
                                "next_reader_count": 1
                            },
                            "debug": {
                                "fast_path": 2
                            }
                        },
                        {
                            "type": "StoredFieldsPhase",
                            "description": "",
                            "time_in_nanos": 672,
                            "breakdown": {
                                "process_count": 2,
                                "process": 361,
                                "next_reader": 311,
                                "next_reader_count": 1
                            }
                        }
                    ]
                }
            },
            {
                "id": "[eMTQVBxNRHSgXOlKr-wicw][field-name-index-phrase-geonames][2]",
                "node_id": "eMTQVBxNRHSgXOlKr-wicw",
                "shard_id": 2,
                "index": "field-name-index-phrase-geonames",
                "cluster": "(local)",
                "searches": [
                    {
                        "query": [
                            {
                                "type": "PhraseQuery",
                                "description": "name._index_phrase:\"hall of of jehovahs\"",
                                "time_in_nanos": 469877,
                                "breakdown": {
                                    "set_min_competitive_score_count": 0,
                                    "match_count": 357,
                                    "shallow_advance_count": 0,
                                    "set_min_competitive_score": 0,
                                    "next_doc": 82265,
                                    "match": 101038,
                                    "next_doc_count": 365,
                                    "score_count": 357,
                                    "compute_max_score_count": 0,
                                    "compute_max_score": 0,
                                    "advance": 0,
                                    "advance_count": 0,
                                    "count_weight_count": 0,
                                    "score": 49147,
                                    "build_scorer_count": 18,
                                    "create_weight": 174003,
                                    "shallow_advance": 0,
                                    "count_weight": 0,
                                    "create_weight_count": 1,
                                    "build_scorer": 63424
                                }
                            }
                        ],
                        "rewrite_time": 790,
                        "collector": [
                            {
                                "name": "QueryPhaseCollector",
                                "reason": "search_query_phase",
                                "time_in_nanos": 176603,
                                "children": [
                                    {
                                        "name": "TopScoreDocCollector",
                                        "reason": "search_top_hits",
                                        "time_in_nanos": 142909
                                    }
                                ]
                            }
                        ]
                    }
                ],
                "aggregations": [

                ]
            }
        ]
    }
}

```

Comparing the two query modes, the hits.total is the same, but the single hits result sets are different. If the same query is changed to the shingles method, the hits results are different, which is considered a problem. What do you think about this problem? Thanks for your answer.

---

<div class="post-metadata">

### Author: ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)
#### Post date: [October 13, 2025, 12:49pm UTC](https://discuss.elastic.co/t/phrase-query-using-shingles-index-phrases-results-in-inconsistent-results-with-the-default-query-method/382625/2 "2025-10-13T12:49:02Z")

</div>

Welcome to the forum @fangqingsong and I hope someone is able to help you. Unfortunately your post is almost un-readable. Some might take the trouble to parse it, but I fear most will not.

As well as using the formatting features the forum supports, you might wish to reduce the content to the minimum that illustrates your issue.

e.g. your query and mapping

```auto
GET yourindex/_search
{
  "size": 2,
  "track_total_hits": true,
  "profile": true,
  "query": {
    "match_phrase": {
      "name": "hall of jehovahs"
    }
  }
}

```

```auto
{
  "yourindex": {
    "mappings": {
      "name": {
        "full_name": "name",
        "mapping": {
          "name": {
            "type": "text",
            "fields": {
              "raw": {
                "type": "text",
                "analyzer": "standard"
              }
            },
            "analyzer": "standard",
            "index_phrases": true
          }
        }
      }
    }
  }
}

```

has exactly same substantive info, but is **way** easier to read.
