0

I'm working on setting up search with the Search API module and Elasticsearch, for the Japanese language.

Following what described in How to implement Japanese full-text search in Elasticsearch, I created an EventSubscriber class to change the index settings and the field mappings.

The search is working fine. The problem is with the autocomplete: I do not get results.

Following what described in Implementing Japanese autocomplete suggestions in Elasticsearch, I am not able to make my code work, since it's based on keyword not fullText field.

public function overrideMapping(Event $event) {
  $params = $event->getIndexMappingParams();

  foreach ($params['body']['properties'] as $key => &$value) {
    if ($value['type'] == 'text') {
      $value['search_analyzer'] = 'ja_kuromoji_search_analyzer';
      $value['analyzer'] = 'ja_kuromoji_index_analyzer';
      $value['fields'] = [
        'ngram' => [
          "type" => "text",
          "search_analyzer" => "ja_ngram_search_analyzer",
          "analyzer" => "ja_ngram_index_analyzer"
        ],
        'suggest' => [
          'type' => 'text',
          'search_analyzer' => 'suggest_search_analyzer',
          'analyzer' => 'suggest_index_analyzer'
        ],
        'readingform' => [
          'type' => 'text',
          'search_analyzer' => 'readingform_search_analyzer',
          'analyzer' => 'readingform_index_analyzer'
        ]
      ];
    }
  }

  $event->setIndexMappingParams($params);
} 

The settings are the same in the autocomplete documentation.

Do you have any idea about this?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.