How to add Multiple analyzers to a field


(anvesh) #1

I am working on ES 6.4.2, want to apply multiple analyzers to a field. I am looking to apply snowball and stop word. I tried thie below mapping is this the correct apporach.

PUT /some-index
{
    "settings": {
        "index": {
            "number_of_shards": 5,
            "number_of_replicas": 1,
            "refresh_interval": "60s",
            "analysis" : {
              "analyzer" : {
                "my_analyzer" : {
                    "tokenizer" : "standard",
                    "filter" : ["standard", "lowercase", "my_snow"]
               },
               "stop_analyzer": {
                 "type":       "stop",
                 "stopwords":  "_english_"
               }
              } ,


              "filter" : {
                "my_snow" : {
                    "type" : "snowball",
                    "language" : "Lovins"
                }
            }
        }
        }
    },
    "mappings": {
        "doc": {
            "_source": {
                "enabled": true
            },
            "properties": {
                "content": {
                    "type": "text",
                    "index": "true",
                    "store": true,
                     "analyzer":["my_analyzer","stop_analyzer"],
                     "search_analyzer": "my_analyzer"
                },

                "title": {
                    "type": "text",
                    "index": "true",
                    "store": true,
                            "analyzer":["my_analyzer","stop_analyzer"],
                            "search_analyzer": "my_analyzer"

                }
            }
        }
    }
}

(Alexander Reelsen) #2

you may want to check out multi fields

--Alex


(Jasmeet) #3

You could change the dbl_metaphone and shingle analysers
indent preformatted text by 4 spaces
{
"settings": {
"index.mapping.total_fields.limit": 2000,
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase","custom_edge_ngram"]
},
"dbl_metaphone":{
"type": "custom",
"tokenizer": "standard",
"filter": ["dbl_metaphone"]
},
"shingle":{
"type": "custom",
"tokenizer": "standard",
"filter": ["shingle-filter"]
}
},
"filter": {
"custom_edge_ngram": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 10
},
"dbl_metaphone": {
"type": "phonetic",
"encoder": "double_metaphone"
},
"shingle-filter": {
"max_shingle_size": "5",
"min_shingle_size": "2",
"output_unigrams": "false",
"type": "shingle"
}
}}}},

"mappings": {
"_doc": {
--------------------------
"content": {
"type": "text"
"index_analyzer": "default",
"search_analyzer" : "standard",
"fields:{
"phonetic":{
"type":"text",
"analyzer":"dbl_metaphone"
},
"shingle":{
"type":"text",
"analyzer":"shingle"
}
}
},
indent preformatted text by 4 spaces


(system) #4

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