简体   繁体   中英

analyzer on field [filename] must be set when search_analyzer is set. elasticsearch error

Am getting the below error message while am setting mappings for my elasticsearch index_analyzer

Please find the error messages below

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "analyzer on field [filename] must be set when search_analyzer is set"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [doc]: analyzer on field [filename] must be set when search_analyzer is set",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "analyzer on field [filename] must be set when search_analyzer is set"
    }
  },
  "status": 400
}

Please find the mapping details that i tried

PUT /documents_test8
{
   "settings" : {
      "analysis" : {
         "analyzer" : {
            "filename_search" : {
               "tokenizer" : "filename",
               "filter" : ["lowercase"]
            },
            "filename_index" : {
               "tokenizer" : "filename",
               "filter" : ["lowercase","edge_ngram"]
            }
         },
         "tokenizer" : {
            "filename" : {
               "pattern" : "[^\\p{L}\\d]+",
               "type" : "pattern"
            }
         },
         "filter" : {
            "edge_ngram" : {
               "side" : "front",
               "max_gram" : 20,
               "min_gram" : 1,
               "type" : "edgeNGram"
            }
         }
      }
   },
   "mappings" : {
      "doc" : {
         "properties" : {
            "filename" : {
               "type" : "text",
               "search_analyzer" : "filename_search",
               "index_analyzer" : "filename_index"
            }
         }
      }
   }
}

The index_analyzer property doesn't exist anymore, you need to use analyzer instead

"mappings" : {
  "doc" : {
     "properties" : {
        "filename" : {
           "type" : "text",
           "search_analyzer" : "filename_search",
           "analyzer" : "filename_index"              <-- change this
        }
     }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM