Field alias in a dynamic template while defining a index mapping

22 Views Asked by At

I am trying to update my field mappings to making a search easier.

The field mappings I have defined in my project handle all the static fields and I have a dynamic template to add new fields that the user needs into a separate key, lets call it Keywords. The users have a search window where they can search using fields Eg.

id: (>5 AND <10)

Now, if they want to search for their custom fields they need to search the following way

Keywords.{field_name}: {search_text}

I want to let the users be able to search without adding Keyword as in:

{field_name}: {search_text}

This is my dynamic template:

{
   "KeywordsTemplate": {
      "match_mapping_type": "string",
      "path_match": "Keywords.*",
      "mapping": {
         "type": "keyword",
         "fields": {
            "text": {
              "type": "text"
            }
         }
      }
   }
}

Is that possible?

Thank you guys. I'm new in elasticsearch

0

There are 0 best solutions below