2014-06-22 7 views
8

예를 들어 여러 필드의 텍스트 내에서 검색하려면 탄성 검색에서 쿼리를 작성하려고합니다. 제목과 설명이 필드이고 "obama", " 세계 ","뉴스 "등이 있습니다. 내가 검색 tryed 여기 탄성 웹 사이트에서 정보를 발견했습니다
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#_literal_fields_literal_and_per_field_boosting 을하지만 그것은 오류 발생이 구조를 시도 할 때이 문제는 다음과 같습니다
첫째 :탄성 검색 여러 필드에서 여러 키워드 검색

{ 
    "multi_match" : { 
    "query":  "obama world news", 
    "type":  "cross_fields", 
    "fields":  [ "Title", "Description" ], 
    "operator": "and" 
    } 
} 

그것은 다음과 같은 오류가 발생을 :

{ 
    "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][0]: SearchParseException[[republishan2][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n }]]]; nested: SearchParseException[[republishan2][0]: from[-1],size[-1]: Parse Failure [No parser for element [multi_match]]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][3]: SearchParseException[[republishan2][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n }]]]; nested: SearchParseException[[republishan2][3]: from[-1],size[-1]: Parse Failure [No parser for element [multi_match]]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][4]: SearchParseException[[republishan2][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n }]]]; nested: SearchParseException[[republishan2][4]: from[-1],size[-1]: Parse Failure [No parser for element [multi_match]]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][1]: SearchParseException[[republishan2][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n }]]]; nested: SearchParseException[[republishan2][1]: from[-1],size[-1]: Parse Failure [No parser for element [multi_match]]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][2]: SearchParseException[[republishan2][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [ {\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n }]]]; nested: SearchParseException[[republishan2][2]: from[-1],size[-1]: Parse Failure [No parser for element [multi_match]]]; }]", 
    "status": 400 
} 

는 또한이 쿼리 시도 :

{ 
    "sort": { 
     "re_max": { 
      "order": "desc" 
      } 
      }, 
    "query": { 
     "multi_match" : { 
     "query":  "obama world news", 
     "type":  "cross_fields", 
     "fields":  [ "Title", "Description" ], 
     "operator": "and" 
     } 
    }, 
    "from": 0, 
    "size": 30} 
} 
,369을

{ 
    "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][0]: SearchParseException[[republishan2][0]: from[-1],size[-1],sort[<custom:\"re_max\": org.elasticse[email protected]1ef6a497>!]: Parse Failure [Failed to parse source [{\n\t\"sort\": {\n\t\t\"re_max\": {\n\t\t\t\"order\": \"desc\"\n\t\t\t}\n\t\t\t}, \n\t{\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n\t},\n\t\"from\": 0, \n\t\"size\": 30}\n}]]]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [[email protected]; line: 7, column: 3]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][3]: SearchParseException[[republishan2][3]: from[-1],size[-1],sort[<custom:\"re_max\": org.elasticse[email protected]364d93ed>!]: Parse Failure [Failed to parse source [{\n\t\"sort\": {\n\t\t\"re_max\": {\n\t\t\t\"order\": \"desc\"\n\t\t\t}\n\t\t\t}, \n\t{\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n\t},\n\t\"from\": 0, \n\t\"size\": 30}\n}]]]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [[email protected]; line: 7, column: 3]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][4]: SearchParseException[[republishan2][4]: from[-1],size[-1],sort[<custom:\"re_max\": org.elasticse[email protected]6e98bb14>!]: Parse Failure [Failed to parse source [{\n\t\"sort\": {\n\t\t\"re_max\": {\n\t\t\t\"order\": \"desc\"\n\t\t\t}\n\t\t\t}, \n\t{\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n\t},\n\t\"from\": 0, \n\t\"size\": 30}\n}]]]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [[email protected]; line: 7, column: 3]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][1]: SearchParseException[[republishan2][1]: from[-1],size[-1],sort[<custom:\"re_max\": org.elasticse[email protected]6c0543f7>!]: Parse Failure [Failed to parse source [{\n\t\"sort\": {\n\t\t\"re_max\": {\n\t\t\t\"order\": \"desc\"\n\t\t\t}\n\t\t\t}, \n\t{\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n\t},\n\t\"from\": 0, \n\t\"size\": 30}\n}]]]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [[email protected]; line: 7, column: 3]]; }{[0CTkBM0pQGK1MzYEDlrpcQ][republishan2][2]: SearchParseException[[republishan2][2]: from[-1],size[-1],sort[<custom:\"re_max\": org.elasticse[email protected]215084be>!]: Parse Failure [Failed to parse source [{\n\t\"sort\": {\n\t\t\"re_max\": {\n\t\t\t\"order\": \"desc\"\n\t\t\t}\n\t\t\t}, \n\t{\n  \"multi_match\" : {\n  \"query\":  \"obama world news\",\n  \"type\":  \"cross_fields\",\n  \"fields\":  [ \"Title\", \"Description\" ],\n  \"operator\": \"and\"\n  }\n\t},\n\t\"from\": 0, \n\t\"size\": 30}\n}]]]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: [[email protected]; line: 7, column: 3]]; }]", 
    "status": 400 
} 

내가 쿼리를 실행하는 우체부 나머지 클라이언트를 사용하고 있습니다 : 1,363,210

는 그리고 이것은 결과입니다. 내 코드의 문제점은 무엇입니까?

답변

18

는 희망이 도움이

{ 
"query": { 
    "multi_match": { 
    "query":  "obama world news", 
    "type":  "cross_fields", 
    "fields":  [ "Title", "Description" ], 
    "operator": "and" 
    } 
}, 
"from": 0, 
"size": 20, 
"sort": [ 
    { 
     "re_max": { 
     "order": "desc" 
     } 
    } 
] 
} 

같은 시도 ..!

관련 문제