2016-07-13 3 views
1

36-3031.00|36-3021.0036-3031.0036-3021.00の文字列を|の区切り文字でトークン化する必要があります。弾性検索の区切り文字に基づいて文字列をトークン化

私はこのように試してみましたが、

PUT text 
{ 
    "test1": { 
    "settings": { 
    "analysis" : { 
      "tokenizer" : { 
       "pipe_tokenizer" : { 
        "type" : "pattern", 
        "pattern" : "|" 
       } 
      }, 
      "analyzer" : { 
       "pipe_analyzer" : { 
        "type" : "custom", 
        "tokenizer" : "pipe_tokenizer" 
       } 
      } 
     } 
    }, 
    "mappings": { 
    "mytype": { 
     "properties": { 
     "text": { 
      "type": "string", 
      "analyzer": "pipe_analyzer" 
     } 
     } 
    } 
    } 
}} 

しかし、それは正確な生産does't。誰でもこのユースケースを整理できますか?

答えて

1

正しいマッピング(REST PUTコマンドのインデックス名を含む)は次のとおりです。そして|文字をエスケープする必要があります

DELETE test1 
PUT test1 
{ 
    "settings": { 
    "analysis": { 
     "tokenizer": { 
     "pipe_tokenizer": { 
      "type": "pattern", 
      "pattern": "\\|" 
     } 
     }, 
     "analyzer": { 
     "pipe_analyzer": { 
      "type": "custom", 
      "tokenizer": "pipe_tokenizer" 
     } 
     } 
    } 
    }, 
    "mappings": { 
    "mytype": { 
     "properties": { 
     "text": { 
      "type": "string", 
      "analyzer": "pipe_analyzer" 
     } 
     } 
    } 
    } 
} 

POST /test1/mytype/1 
{"text":"36-3031.00|36-3021.00"} 

GET /test1/_analyze 
{"field":"text","text":"36-3031.00|36-3021.00"} 
+0

GET/test1の/ _analyze { "フィールド": "のproductID"、 "テキスト": "36から3031.00 | 36〜3021.00" }それはのように分割します36,3031.00,36,3021.00 –

+0

これは、あなたが私の指示に正確に従わなかったことを意味します。私は完全なテストで私の答えを更新しました。 –

関連する問題