1
PUT /new_index/
{
    "settings": {
        "index": {
            "type": "default"
        },
        "number_of_shards": 5,
        "number_of_replicas": 1,
        "analysis": {
            "filter": {
                "ap_stop": {
                    "type": "stop",
                    "stopwords_path": "stoplist.txt"
                },
                "shingle_filter" : {
                    "type" : "shingle",
                    "min_shingle_size" : 2,
                    "max_shingle_size" : 5,
                    "output_unigrams": true
                }
            },
        "analyzer": {
             "aplyzer": {
                "type": "custom",
                "tokenizer": "standard",
                "filter": ["standard",
                           "ap_stop",
                           "lowercase",
                           "shingle_filter",
                           "snowball"]
                }
            }
        }
    }
}

PUT /new_index/document/_mapping/
{
    "document": {
        "properties": {
            "text": {
                "type": "string",
                "store": true,
                "index": "analyzed",
                "term_vector": "with_positions_offsets_payloads",
                "search_analyzer": "aplyzer",
                "index_analyzer": "aplyzer"
            },
            "original_text": {
                "include_in_all": false,
                "type": "string",
                "store": false,
                "index": "not_analyzed"
            },
            "docid": {
                "include_in_all": false,
                "type": "string",
                "store": true,
                "index": "not_analyzed"  
            }
        }
    }
}

settings上記のインデックスを でmappings受け入れられるタイプに変換する必要がありelastic4sます。私は最新のものを使用しelastic4sていelasticsearch 1.5.2ます。

ドキュメントに記載されているいくつかの例を調べましたが、この方法で作成しようとしたように、その方法がわかりません。

client.execute {
    create index "new_index" mappings {
      "documents" as (
        "text" typed StringType analyzer ...
        )
    }
  }

PUT リクエストで指定された 、 などのstore使用index方法がわかりません。term_vectors

更新: 答えに基づいて、私はこの種のものを作ることができました:

create index "new_index" shards 5 replicas 1 refreshInterval "90s"  mappings {
    "documents" as(
      id typed StringType analyzer KeywordAnalyzer store true includeInAll false,
      "docid" typed StringType index "not_analyzed" store true includeInAll false,
      "original_text" typed StringType index "not_analyzed" includeInAll false,
      "text" typed StringType analyzer CustomAnalyzer("aplyzer") indexAnalyzer "aplyzer" searchAnalyzer "aplyzer" store true termVector WithPositionsOffsetsPayloads
      )
  } analysis (
    CustomAnalyzerDefinition(
      "aplyzer",
      StandardTokenizer,
      LowercaseTokenFilter,
      shingle tokenfilter "shingle_filter" minShingleSize 2 maxShingleSize 5 outputUnigrams true
    )
  )

私が今理解できないのは、スノーボール ステマーとストップ ワードのファイル パスをaplyzerアナライザーに追加する方法です。

どうすればいいですか?

4

2 に答える 2

1

タイトルではカスタム フィルターについて質問していますが、質問の本文ではstoreindex、およびについて質問していますterm_vectors。後者について説明します。

  client.execute {
    create index "myindex" mappings {
      "mytype" as (
        "myfield" typed StringType store true termVector termVector.WithOffsets index "not_analyzed"
        )
      )
    }
  }

更新

更新された質問に基づいています。Elasticsearch のドキュメントでは、スノーボール トークン フィルターにストップワードを設定できるかどうかが明確ではありません。スノーボールアナライザーでできます。

だから、どちらか

SnowballAnalyzerDefinition("mysnowball", "English", stopwords = Set("I", "he", "the"))

また

CustomAnalyzerDefinition("mysnowball",
  StandardTokenizer,
  LowercaseTokenFilter,
  snowball tokenfilter "snowball1" language "German"
)
于 2015-06-03T18:11:11.407 に答える