Shingles not working with odd no. of search words

Stackoverflow Link

Any help will be appreciated

which ES version are you using?

I ran the following on ES 5.1.2 and it looks fine to me:

DELETE search

PUT search
{
  "settings": {
    "index": {
      "analysis": {
        "filter": {
          "my_shingle_filter": {
            "max_shingle_size": "2",
            "min_shingle_size": "2",
            "output_unigrams": "false",
            "type": "shingle"
          },
          "autocomplete_filter": {
            "type": "edge_ngram",
            "min_gram": "1",
            "max_gram": "40"
          }
        },
        "analyzer": {
          "my_shingle_analyzer": {
            "filter": [
              "lowercase",
              "my_shingle_filter"
            ],
            "type": "custom",
            "tokenizer": "whitespace"
          },
          "shingle_with_autocomplete": {
            "filter": [
              "lowercase",
              "my_shingle_filter",
              "autocomplete_filter"
            ],
            "type": "custom",
            "tokenizer": "whitespace"
          }
        }
      }
    }
  },
  "mappings": {
    "address": {
      "properties": {
        "full_address": {
          "type": "text",
          "norms": false,
          "fields": {
            "shingles": {
              "type": "text",
              "norms": false,
              "analyzer": "shingle_with_autocomplete"
            }
          },
          "analyzer": "whitespace"
        }
      }
    }
  }
}


PUT search/address/581c50297fd84ecc35420570
{
  "full_address": "new delhi nagar palika adarsh vidyalay new delhi nagar palika adarsh vidyalay tilak lane tilak marg area new delhi delhi 110001"
}

PUT search/address/581c502a7fd84ecc35422010
{
  "full_address": "kingdom hall of jehovant witness gyan bharti public school saket new delhi new delhi delhi 110017"
}

GET search/address/_search?_source=full_address
{
  "query": {
    "match": {
      "full_address.shingles": {
        "query": "new delhi",
        "analyzer": "my_shingle_analyzer"
      }
    }
  }
}

GET search/address/_search?_source=full_address
{
  "query": {
    "match": {
      "full_address.shingles": {
          "query": "new delhi nag",
          "analyzer": "my_shingle_analyzer"
      }
    }
  }
}

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