2014-06-22 18 views
8

Tôi đang cố tạo truy vấn trong tìm kiếm Đàn hồi để tìm kiếm bên trong văn bản của nhiều trường, ví dụ: Tiêu đề và Mô tả là các trường và tôi muốn tìm kiếm "obama", " thế giới "," tin tức "bên trong 3 trường này. Tôi đã tryed tìm kiếm và tìm thấy thông tin trong trang web đàn hồi ở đây:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#_literal_fields_literal_and_per_field_boosting Nhưng vấn đề là khi tôi cố gắng kết cấu này nó tạo ra lỗi:
Đầu tiên:Tìm kiếm nhiều từ khóa trong nhiều trường

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

Nó tạo ra lỗi như thế này:

{ 
    "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 
} 

tôi cũng đã cố gắng truy vấn này:

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

Và đây là kết quả:

{ 
    "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 
} 

Tôi đang sử dụng ứng dụng khách Postman Rest để chạy truy vấn. Vấn đề với mã của tôi là gì?

Trả lời

18

Hãy thử như thế này

hy vọng nó sẽ giúp ..!

Các vấn đề liên quan