# 部分一致の曖昧検索について

**URL:** https://discuss.elastic.co/t/topic/207614
**Category:** 日本語による質問・議論はこちら
**Created:** [November 13, 2019, 2:30am UTC](https://discuss.elastic.co/t/topic/207614 "2019-11-13T02:30:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![b18bd8be4bf795b30ee7](https://avatars.discourse-cdn.com/v4/letter/b/3e96dc/32.png) [@b18bd8be4bf795b30ee7](https://discuss.elastic.co/u/b18bd8be4bf795b30ee7)
#### Post date: [November 13, 2019, 2:30am UTC](https://discuss.elastic.co/t/topic/207614/1 "2019-11-13T02:30:28Z")

</div>

match\_phrase queryと曖昧検索を組み合わせたような検索をしたいと考えております。  
バージョン：Elasticsearch6.3（AWSのElasticsearch Serviceを使用しております。）

具体的には

データ1：(株)テスト春夏秋冬  
データ2：株式会社テスト冬秋夏春

が存在するとして、下記2点を実現させたいです。

①『テスあ春』で検索を実行した場合、１だけをヒットさせる。  
②『株式会社テスあ』で検索を実行した場合、１と2をヒットさせる。

**試したこと**  
データのtokenizerをicu\_tokenizerにして類義語を設定し、match queryでfuzzinessを定義しました。①②ともにデータ2のみがヒットしました。（何故このような結果となるのかは理解できております。）

■Index

```
PUT test_index_1
{
  "settings" : {
    "index": {
      "number_of_shards" : 1,
      "number_of_replicas" : 0,
      "analysis":{
        "filter":{
          "synonym": {
            "type": "synonym",
            "synonyms": [
              "(株)=>株式会社"
              ]
          }
        },
        "analyzer": {
          "test_analyzer": {
            "type": "custom",
            "tokenizer": "icu_tokenizer",
            "filter": [
              "synonym"
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "type": {
      "properties": {
        "name" : {
          "type" : "text",
          "analyzer" : "test_analyzer"
        }
      }
    }
  }
}

```

■データ

```
PUT test_index_1/type/1
{"name":"(株)テスト春夏秋冬"}
PUT test_index_1/type/2
{"name":"株式会社テスト冬秋夏春"}

```

■検索クエリ  
①

```
GET test_index_1/_search
{
  "query": {
    "match" : {
      "name" : {
        "query": "テスあ春",
        "fuzziness": "2",
        "operator" : "and"
      }
    }
  }
}

```

②

```
GET test_index_1/_search
{
  "query": {
    "match" : {
      "name" : {
        "query": "株式会社テスあ",
        "fuzziness": "2",
        "operator" : "and"
      }
    }
  }
}

```

部分一致の曖昧検索を実現したい為、フレーズ検索を調べましたが、match\_phrase queryにfuzzinessは使用できないようなので、別のアプローチがあれば、ご教示いただければと思います。

よろしくお願いいたします。

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 11, 2019, 2:30am UTC](https://discuss.elastic.co/t/topic/207614/2 "2019-12-11T02:30:35Z")

</div>

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