2016-07-06 7 views
0

ネストされたフィールドabc.answerでアナライザを使用していないクエリ文字列をヒットしようとしています。ここで私が使用しているクエリは次のとおりです。elasticsearch内のネストされたフィールドのクエリ文字列(作成方法と作成方法)

{ 
    "query": { 
     "nested":{ 
      "path": "abc", 
      "query":{ 
    "query_string": { 
     "query": "photo AND delhi", 
     "fields": ["answer"] 



    } 
    }, 
    "inner_hits": { 
      "explain": true 
     } 

    } 
    }, 
    "explain" : true, 
    "sort" : [ { 
    "_score" : { } 
    } ] 
} 

私は、ネストされたフィールドabcdtp operatorbangaloreの両方を持つ文書を検索します。しかし、それは結果を示していません。

マイネストされたフィールド構造:

"abc": [ 
      { 
       "updatedAt": 1452073190000, 
       "questionId": 1, 
       "labelOriginal": "name", 
       "createdAt": 1452073190000, 
       "answerOriginal": "wexe", 
       "answer": "wexe", 
       "answerId": 0, 
       "label": "name", 
       "question": "what is your name?" 
      }, 
      { 
       "updatedAt": 1452073190000, 
       "questionId": 2, 
       "labelOriginal": "mobile", 
       "createdAt": 1452073190000, 
       "answerOriginal": "9000000000", 
       "answer": "9000000000", 
       "answerId": 0, 
       "label": "mobile", 
       "question": "What is your mobile number?" 
      }, 
      { 
       "updatedAt": 1452073190000, 
       "questionId": 3, 
       "labelOriginal": "email id", 
       "createdAt": 1452073190000, 
       "answerOriginal": "[email protected]", 
       "answer": "[email protected]", 
       "answerId": 0, 
       "label": "email Id", 
       "question": "What is your e-mail id ?" 
      }, 
      { 
       "updatedAt": 1452073190000, 
       "questionId": 4, 
       "labelOriginal": "current role", 
       "createdAt": 1452073190000, 
       "answerOriginal": "dtp operator", 
       "answer": "DTP Operator", 
       "answerId": 597, 
       "label": "current role", 
       "question": "What is your current role?" 
      }, 
      { 
       "updatedAt": 1452073190000, 
       "questionId": 5, 
       "labelOriginal": "city", 
       "createdAt": 1452073190000, 
       "answerOriginal": "bangalore", 
       "answer": "Bangalore", 
       "answerId": 23, 
       "label": "city", 
       "question": "Which city do you live in ?" 
      }, 
      { 
       "updatedAt": 1452073190000, 
       "questionId": 6, 
       "labelOriginal": "locality", 
       "createdAt": 1452073190000, 
       "answerOriginal": "80 ft. road", 
       "answer": "80 Ft. Road", 
       "answerId": 0, 
       "label": "locality", 
       "question": "Which locality do you live in ?" 
      }, 
      { 
       "updatedAt": 1452073190000, 
       "questionId": 13, 
       "labelOriginal": "job type", 
       "createdAt": 1452073190000, 
       "answerOriginal": "part time jobs", 
       "answer": "Part Time Jobs", 
       "answerId": 64, 
       "label": "Job Type", 
       "question": "Are you comfortable with working Full Time or Part Time?" 
      }, 
      { 
       "labelOriginal": "userDesiredCity", 
       "answerOriginal": "bangalore", 
       "answer": "Bangalore", 
       "answerId": 23, 
       "label": "userDesiredCity" 
      } 

答えて

0

は、クエリのこの種のnested機能が、単純な配列のフラットな構造を必要としません。

"rsa": { 
     "type": "nested", 
     "include_in_parent": true, 
     "properties": { 

再インデックステストドキュメントと、この1(なしnestedクエリ)のようなクエリを使用します:

"query": { 
    "query_string": { 
     "query": "dtp operator AND bangalore", 
     "fields": [ 
     "rsa.answer" 
     ] 
    } 
    } 
+0

は私が変更できない場合

は、あなたのrsaフィールドがinclude_in_parent: trueを持つようにしてくださいマッピング、私は既存のマッピングでこれを行うことはできませんか?同じクエリでない場合は、私が期待している結果に類似したものがあります。ありがとう –

+0

私はそうは思わない。 –

関連する問題