2016-04-29 14 views
-1

私はelasticsearchに取り組んでいて、単語が時間検索レコードの行に何回出てくるかという問題に直面しています。 私は以下の持っているように行:私たちが弾性検索の行に単語を持っている回数を見つけよう

{ 
{ "user":"Aniket", "postDate":"2016-04-26","body":"Search as we discuss yesterday one time word", "title":"One time word"} 
}, 
{ 
"user": "aniket", "postDate": "2016-04-26", "body": "Distribution is hard. Distribution should be easy.word word word word" , "title": "Four times word"} 
}, 
{"user": "aniket", "postDate": "2016-04-26", "body": "Distribution is hard. Distribution should be easy.word word word" , "title": "Three times word"} 
}, 
{"user": "aniket", 
"postDate": "2016-04-26", 
"body": "Distribution is hard. Distribution should be easy.word word" , 
"title": "Two times word" 
} 

私は、ユーザーaniket下4行の上に持っていると私たちはそれぞれの行に「言葉」を持っていますが、時にはそれが2、3、4または1時間になります。私は「単語」を検索した場合と同じように結果が必要です。単語の単語の単語の単語の単語の単語の単語の単語の単語スコアはあまりにも高いですが、スコアは私にそれに関する情報を提供するつもりはありません。

私は次のクエリ

curl -XGET 'localhost:9200/blog/post/_search?pretty=1' -d '{ 
"query": { 
"match": { 
"body": "word" 
} 
}, 
"sort": { 
"_script": { 
"type": "number", 
"script": "termInfo=_index['body'][term].tf();return termInfo;", 
"params": { 
"term": "word" 
}, 
"lang": "groovy", 
"order": "desc" 
} 
} 
}' 

と、このエラーを取得しようとしています:私は私のクエリの並べ替えの一部を削除した場合、私は、単純なソートを使用している場合でも、その私に結果を与えるよりも、

{ 
"index" : "blog", 
"shard" : 4, 
"status" : 500, 
"reason" : "QueryPhaseExecutionException[[blog][4]: query[filtered(body:word)->cache(type:post)],from[0],size[10],sort[script\": org.elasticsearch.index.f[email protected]51c07776>!]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[MissingPropertyException[No such property: body for class: Script5]]; " 
} ] 

をそれから、それは正しく働いていますが、私たちの言葉の場合はそうではありません。そのための解決策と私が逃しているものは何ですか?

+0

は、以下の手順に従ってください:のhttp://ブログ.rnf.me/2013/exact-substring-search-in-elasticsearch.html –

+0

他の投稿で尋ねられたように - http://stackoverflow.com/questions/36889503/find-number-of-times-we-弾力的な検索を行えるキャラクターを持っている"curl -XGET"のutput http:// localhost:9200/blog/post/_search "-d" {"query":{"match_all":{}}、 "size":1} –

答えて

0

sort result by term frequency countに私の指示に従い、 "_explanation" の内容を確認してください:

単語の数がある
"_explanation": { 
      "value": 0.16608895, 
      "description": "weight(_all:godfather in 0) [PerFieldSimilarity], result of:", 
      "details": [ 
      { 
       "value": 0.16608895, 
       "description": "fieldWeight in 0, product of:", 
       "details": [ 
       { 
        "value": 1.7320508, 
        "description": "tf(freq=3.0), with freq of:", 
        "details": [ 
        { 
         "value": 3, 
         "description": "termFreq=3.0", 
         "details": [] 
        } 
        ] 
       }, 
       { 
        "value": 0.30685282, 
        "description": "idf(docFreq=1, maxDocs=1)", 
        "details": [] 
       }, 
       { 
        "value": 0.3125, 
        "description": "fieldNorm(doc=0)", 
        "details": [] 
       } 
       ] 
      } 
      ] 
     } 

"value": 3, 
"description": "termFreq=3.0", 
"details": [] 
関連する問題