Cześć ElasticSearch przyjaciele chciałem ustawić limit czasu, kiedy szukam. Więc umieść setestimeout w Searchequestbuilder do 10s. Ale za każdym razem, gdy stałem się porażką analizy z moim zapytaniem. Nie rozumiem dlaczego.

Oto mój SearchController z ustalaniem:

@RestController
public class SearchController {
@Autowired
@Named("es")
private Node node;

@RequestMapping(method = RequestMethod.GET, value = "/search/{query}")
public List<Hit> search(@PathVariable("query") String query){
    Client client = node.client();
    List<Hit> esData = new ArrayList<Hit>();

    SearchRequestBuilder request1 = client.prepareSearch("orange11").setTimeout("10s").setQuery(query);

    SearchResponse response1 = request1.execute().actionGet();

    System.out.println("Hits: "+response1.getHits());

    for(SearchHit hit : response1.getHits()){

        Hit hitDto = new Hit(hit.getSource());
        Map<String, HighlightField> highlightFields = hit.getHighlightFields();
        for(String s : highlightFields.keySet()){
            List<String> fragmentsDto = new ArrayList<>();
            Text [] fragments = highlightFields.get(s).fragments();
            for (Text fragment : fragments){
                fragmentsDto.add(fragment.toString());
            }
            hitDto.addField("_all", fragmentsDto);
        }
        esData.add(hitDto);
    }
    return esData;
}


}

Oto wyjątek:

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query], all shards failed; shardFailures {[67Vq8cvCSVm9GROgOY-ifQ][orange11][0]: SearchParseException[[orange11][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"timeout":10000,"query_binary":"eyJzaXplIiA6IDEwLCAiZnJvbSIgOiAwLCAicXVlcnkiIDogeyAibWF0Y2giIDogeyAiX2FsbCIgOiB7InF1ZXJ5IiA6ICJkb2xvcmUifX19LCAiaGlnaGxpZ2h0IiA6IHsiZmllbGRzIiA6IHsgIioiIDoge319LCAicmVxdWlyZV9maWVsZF9tYXRjaCIgOiBmYWxzZX19fQ=="}]]]; nested: QueryParsingException[[orange11] [_na] query malformed, no field after start_object]; }{[67Vq8cvCSVm9GROgOY-ifQ][orange11][1]: SearchParseException[[orange11][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"timeout":10000,"query_binary":"eyJzaXplIiA6IDEwLCAiZnJvbSIgOiAwLCAicXVlcnkiIDogeyAibWF0Y2giIDogeyAiX2FsbCIgOiB7InF1ZXJ5IiA6ICJkb2xvcmUifX19LCAiaGlnaGxpZ2h0IiA6IHsiZmllbGRzIiA6IHsgIioiIDoge319LCAicmVxdWlyZV9maWVsZF9tYXRjaCIgOiBmYWxzZX19fQ=="}]]]; nested: QueryParsingException[[orange11] [_na] query malformed, no field after start_object]; }{[67Vq8cvCSVm9GROgOY-ifQ][orange11][2]: SearchParseException[[orange11][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"timeout":10000,"query_binary":"eyJzaXplIiA6IDEwLCAiZnJvbSIgOiAwLCAicXVlcnkiIDogeyAibWF0Y2giIDogeyAiX2FsbCIgOiB7InF1ZXJ5IiA6ICJkb2xvcmUifX19LCAiaGlnaGxpZ2h0IiA6IHsiZmllbGRzIiA6IHsgIioiIDoge319LCAicmVxdWlyZV9maWVsZF9tYXRjaCIgOiBmYWxzZX19fQ=="}]]]; nested: QueryParsingException[[orange11] [_na] query malformed, no field after start_object]; }{[67Vq8cvCSVm9GROgOY-ifQ][orange11][3]: SearchParseException[[orange11][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"timeout":10000,"query_binary":"eyJzaXplIiA6IDEwLCAiZnJvbSIgOiAwLCAicXVlcnkiIDogeyAibWF0Y2giIDogeyAiX2FsbCIgOiB7InF1ZXJ5IiA6ICJkb2xvcmUifX19LCAiaGlnaGxpZ2h0IiA6IHsiZmllbGRzIiA6IHsgIioiIDoge319LCAicmVxdWlyZV9maWVsZF9tYXRjaCIgOiBmYWxzZX19fQ=="}]]]; nested: QueryParsingException[[orange11] [_na] query malformed, no field after start_object]; }{[67Vq8cvCSVm9GROgOY-ifQ][orange11][4]: SearchParseException[[orange11][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"timeout":10000,"query_binary":"eyJzaXplIiA6IDEwLCAiZnJvbSIgOiAwLCAicXVlcnkiIDogeyAibWF0Y2giIDogeyAiX2FsbCIgOiB7InF1ZXJ5IiA6ICJkb2xvcmUifX19LCAiaGlnaGxpZ2h0IiA6IHsiZmllbGRzIiA6IHsgIioiIDoge319LCAicmVxdWlyZV9maWVsZF9tYXRjaCIgOiBmYWxzZX19fQ=="}]]]; nested: QueryParsingException[[orange11] [_na] query malformed, no field after start_object]; }
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:237)
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.onFailure(TransportSearchTypeAction.java:183)
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:565)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Zapytanie to:

{"size" : 10, "from" : 0, "query" : { "match" : { "_all" : {"query" : "'+searchTerm+'"}}}, "highlight" : {"fields" : { "*" : {}}, "require_field_match" : false}}}

Ustawienia węzła to:

        ImmutableSettings.Builder meineSettings = ImmutableSettings.settingsBuilder();
    meineSettings.put("node.name", "orange11-node");
    meineSettings.put("path.data", "/Users/lucaarchidiacono/IdeaProjects/moap2/MP3_MoapSampleBuild/data/index");
    meineSettings.put("index.store.type", "memory");
    meineSettings.put("http.enabled", false);
0
Luca Archidiacono 17 luty 2017, 12:36

2 odpowiedzi

Najlepsza odpowiedź

Twoje zdekodowane zapytanie jest takie:

{
  "size": 10,
  "from": 0,
  "query": {
    "match": {
      "_all": {
        "query": "dolore"
      }
    }
  },
  "highlight": {
    "fields": {
      "*": {}
    },
    "require_field_match": false
  }
}}

Na koniec masz jeden zbyt wielu kręconych klamry, powinno być

{
  "size": 10,
  "from": 0,
  "query": {
    "match": {
      "_all": {
        "query": "dolore"
      }
    }
  },
  "highlight": {
    "fields": {
      "*": {}
    },
    "require_field_match": false
  }
}          <--- fix this
2
Val 17 luty 2017, 09:39

Spróbuj tego. W milisekundach, a nie sekundy.

GET /_search?timeout=10ms
0
JonyD 17 luty 2017, 09:39