1

I was able to search for a couple of keywords in 2 different fields using the code below:

curl -XGET 'localhost:9200/INDEXED_REPO/_search?pretty' -H 'Content-Type: 
application/json' -d'{"query" : {"constant_score" : {"filter" : {"bool" : 
{"should" : [{ "terms" : {"description" : ["heart","cancer"]}},{ "terms" : 
{"title" : ["heart","cancer"]}}]}}}}}'

However, when I put 15000 keywords, the server suddenly closed my terminal. I am using Mobaxterm. What is the best solution to include this many keywords?

Tariq Khan
  • 5,498
  • 4
  • 28
  • 34
NinaDev
  • 77
  • 9

1 Answers1

0

There is a limit to the Max number of clauses you can use in the bool query. You can change it but it has effects on the CPU usage of the Server and might cause it to crash. I think if you didn't get an error of max clauses reached you might have already crashed the server.

I would find an optimal number that your server can take or if its absolutely necessary to search for all of them at once upgrade the server. setup extra nodes and do shard / replicas properly.

To allow more bool clauses Add the following in your elasticsearch.yml file

"indices.query.bool.max_clause_count : n" (where n - new supported number of clauses)

Refer to these for more details

Also Cerebro is a better alternative to Mobaxterm you can download it from here https://github.com/lmenezes/cerebro. It will give a nice interface to play with the queries before finalizing it in your code.

Tariq Khan
  • 5,498
  • 4
  • 28
  • 34