2016-03-08 5 views
0

Образец документа в elasticsearch:ElasticSearch: Как добавить отображение для поля массива?

{ 
    "name": "Tom", 
    "hobbies": [ 
     { 
      "hobby": "go for a walk" 
     }, 
     { 
      "hobby": "board games" 
     } 
    ] 
} 

Здесь добавляется отображение "Имя":

{ 
    "person": { 
     "_all": { 
      "analyzer": "ik_max_word", 
      "search_analyzer": "ik_max_word", 
      "term_vector": "no", 
      "store": "false" 
     }, 
     "properties": { 
      "name": { 
       "type": "string", 
       "store": "no", 
       "term_vector": "with_positions_offsets", 
       "analyzer": "ik_max_word", 
       "search_analyzer": "ik_max_word", 
       "include_in_all": "true", 
       "boost": 8 
      } 
     } 
    } 
} 

Проблема: Как добавить отображение для hobbies.hobby? Я хочу, чтобы указать это поле для анализатора -> ik_max_word

ответ

0

Хорошо, согласно Object datatype description, это должно быть сделано так:

{ 
    "person": { 
     "_all": { 
      "analyzer": "ik_max_word", 
      "search_analyzer": "ik_max_word", 
      "term_vector": "no", 
      "store": "false" 
     }, 
     "properties": { 
      "name": { 
       "type": "string", 
       "store": "no", 
       "term_vector": "with_positions_offsets", 
       "analyzer": "ik_max_word", 
       "search_analyzer": "ik_max_word", 
       "include_in_all": "true", 
       "boost": 8 
      }, 
      "hobbies": { 
       "properties": { 
        "hobby": { 
         "type": "string", 
         "store": "no", 
         "term_vector": "with_positions_offsets", 
         "analyzer": "ik_max_word", 
         "search_analyzer": "ik_max_word", 
         "include_in_all": "true", 
         "boost": 8 
        } 
       } 
      } 
     } 
    } 
} 
Смежные вопросы