Escape reserved words in elastic search

If the query string contains type reserved words AND

or OR

how to avoid them?

Example 1: Brooklyn AND Bailey

If I query the database, it looks for documents with Brooklyn

and Bailey

instead of a string Brooklyn AND Bailey

.

Example 2: Brooklyn OR Bailey

If I query the database, it looks for documents that have either Brooklyn

or Bailey

instead of a string Brooklyn OR Bailey

.

This is my code.

esclient.search({
  from: 0,
  size: 5,
  body: {
    'query': {
      'query_string': {
        'query': 'title:' + term
      }
    }
  }
}).then(function(body) {
    // results
});

      

How do I avoid reserved words in a query?

+3


source to share





All Articles