Search results with begins with and ending with using wildcard


(R01K) #1

Hi ,

I using custom search /index analyzer as shown below

 "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "custom_search_analyzer": {
            "filter": [
              "lowercase",
              "asciifolding"
            ],
            "type": "custom",
            "tokenizer": "whitespace"
          },
          "custom_index_analyzer": {
            "filter": [
              "lowercase",
              "asciifolding"
            ],
            "type": "custom",
            "tokenizer": "custom_tokenizer"
          }
        },
        "tokenizer": {
          "custom_tokenizer": {
            "type": "ngram",
            "min_gram": "1",
            "max_gram": "10"
          }
        }
      }
    }
  },
  "mappings": {
    "doc": {
      "properties": {
        "my_field": {
          "type": "text",
          "analyzer": "custom_index_analyzer",
          "search_analyzer": "custom_search_analyzer",
          "fields": {
            "keyword": {
              "ignore_above": 256,
              "type": "keyword"
            }
          }
        }
      }
    }

But the problem with this analyzer is when user searches with wildcard query

file*

and expecting results which begins with file but it returns the results like

  1. my_field=myfile.txt
    2.my_field=samplefile.txt

but i want only those results which starts with file , i have tried with prefix query and also match_phase_prefix query but its not working either

Case 2: if user is searching for *.txt then it should return all the documents which is ending with .txt only and not the results which .txt in between.. please help to implement the same?
Kindly help

thanks,
rohan


(system) #2

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