2014-04-14 7 views
0

ElasticSearch를 사용하여 트위터 스트리밍 API에서받은 트윗을 저장하고 있습니다. 그것들을 저장하기 전에 트위터 내용에 영어 줄기를 적용하고 ElasticSearch 분석기를 사용하려고합니다.ElasticSearch의 분석기가 작동하지 않습니다.

이 내가 사용하고있는 현재 템플릿입니다 : 내가 스트리밍을 시작하고 인덱스가 생성되면

PUT _template/twitter 
{ 
    "template": "139*", 
    "settings" : { 
    "index":{ 
     "analysis":{ 
     "analyzer":{ 
      "english":{ 
      "type":"custom", 
      "tokenizer":"standard", 
      "filter":["lowercase", "en_stemmer", "stop_english", "asciifolding"] 
      } 
     }, 
     "filter":{ 
      "stop_english":{ 
      "type":"stop", 
      "stopwords":["_english_"] 
      }, 
      "en_stemmer" : { 
      "type" : "stemmer", 
      "name" : "english" 
      } 
     } 
     } 
    } 
    }, 
    "mappings": { 
    "tweet": { 
     "_timestamp": { 
     "enabled": true, 
     "store": true, 
     "index": "analyzed" 
     }, 
     "_index": { 
     "enabled": true, 
     "store": true, 
     "index": "analyzed" 
     }, 
     "properties": { 
     "geo": { 
      "properties": { 
      "coordinates": { 
       "type": "geo_point" 
      } 
      } 
     }, 
     "text": { 
      "type": "string", 
      "analyzer": "english" 
     } 
     } 
    } 
    } 
} 

, 내가 정의한 모든 매핑이 제대로 적용하는 것,하지만 텍스트가 저장됩니다 완전히 원시, 트위터에서 비롯됩니다. 인덱스 메타 데이터를 보여줍니다 내가 잘못 뭐하는 거지

"settings" : { 
    "index" : { 
     "uuid" : "xIOkEcoySAeZORr7pJeTNg", 
     "analysis" : { 
      "filter" : { 
       "en_stemmer" : { 
        "type" : "stemmer", 
        "name" : "english" 
       }, 
       "stop_english" : { 
        "type" : "stop", 
        "stopwords" : [ 
         "_english_" 
        ] 
       } 
      }, 
      "analyzer" : { 
       "english" : { 
        "type" : "custom", 
        "filter" : [ 
         "lowercase", 
         "en_stemmer", 
         "stop_english", 
         "asciifolding" 
        ], 
        "tokenizer" : "standard" 
       } 
      } 
     }, 
     "number_of_replicas" : "1", 
     "number_of_shards" : "5", 
     "version" : { 
      "created" : "1010099" 
     } 
    } 
}, 
"mappings" : { 
    "tweet" : { 
     [...] 
     "text" : { 
      "analyzer" : "english", 
      "type" : "string" 
     }, 
     [...] 
    } 
} 

? 분석기가 올바르게 적용된 것처럼 보이지만 아무 것도 일어나지 않습니다./

고맙습니다!

PS :

curl -XGET 'http://localhost:9200/_all/_search?pretty' -d '{ 
    "query": { 
    "filtered": { 
     "query": { 
     "bool": { 
      "should": [ 
      { 
       "query_string": { 
       "query": "_index:1397574496990" 
       } 
      } 
      ] 
     } 
     }, 
     "filter": { 
     "bool": { 
      "must": [ 
      { 
       "match_all": {} 
      }, 
      { 
       "exists": { 
       "field": "geo.coordinates" 
       } 
      } 
      ] 
     } 
     } 
    } 
    }, 
    "fields": [ 
    "geo.coordinates", 
    "text" 
    ], 
    "size": 50000 
}' 

이이 분야의 하나로서 막아야 텍스트를 반환해야하지만, 응답은 다음과 같습니다 : 나는 분석기를 실현하는 데 사용하는 검색 쿼리가 적용되지 않는

{ 
    "took": 29, 
    "timed_out": false, 
    "_shards": { 
     "total": 47, 
     "successful": 47, 
     "failed": 0 
    }, 
    "hits": { 
     "total": 2, 
     "max_score": 0.97402453, 
     "hits": [ 
     { 
      "_index": "1397574496990", 
      "_type": "tweet", 
      "_id": "456086643423068161", 
      "_score": 0.97402453, 
      "fields": { 
       "geo.coordinates": [ 
        -118.21122533, 
        33.79349318 
       ], 
       "text": [ 
        "Happy turtle Tuesday ! The week is slowly crawling to Wednesday good morning everyone ☀️#turtles… http://t.co/wAVmcxnf76" 
       ] 
      } 
     }, 
     { 
      "_index": "1397574496990", 
      "_type": "tweet", 
      "_id": "456086701451259904", 
      "_score": 0.97333175, 
      "fields": { 
       "geo.coordinates": [ 
        -81.017636, 
        33.998741 
       ], 
       "text": [ 
        "Tuesday is Twins Day over here, apparently (it's a far too often occurrence) #tuesdaytwinsday… http://t.co/Umhtp6SoX6" 
       ] 
      } 
     } 
     ] 
    } 
} 

텍스트 필드는 Twitter에서 온 텍스트 필드와 똑같습니다 (스트리밍 API를 사용하고 있습니다). 분석기가 적용될 때 텍스트 필드가 줄기를 기대합니다.

+0

"아무 것도 일어나지 않는다"는 것은 무엇을 의미합니까? 분석기는 데이터 저장 방식에 영향을 미치지 않습니다. 데이터가 색인되는 방식에만 영향을 미칩니다. 분석 된 필드에서 형태소 분석이 가능한지 검색하려고 했습니까? 분석기가 적용되는지 보려면 [analyze] (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-analyze.html) 방법을 사용하려고 했습니까? – imotov

+0

사용자 정의 분석기로 analyze 메소드가 작동하지만 GET 쿼리를 사용하여 "text"필드를 검색하려고 할 때 분석기가 적용되지 않아 잘못된 작업이 수행되고 있습니다 :/ – Cea33

+0

검색하려는 데이터 및 작동하지 않는 검색 쿼리 – imotov

답변

1

분석기는 데이터 저장 방식에 영향을 미치지 않습니다. 따라서 어떤 분석기를 사용하든 관계없이 소스 및 저장된 필드에서 동일한 텍스트를 다시 얻을 수 있습니다. 분석기는 검색 할 때 적용됩니다. 따라서 text:twin과 같은 것을 검색하고 Twins이라는 단어로 레코드를 찾으면 형태소 분석기가 적용된 것입니다.