Skip to content

A quick-and-dirty "string to Elasticsearch query" parser

Notifications You must be signed in to change notification settings

pcbje/es-auto-query

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

es-auto-query

A quick-and-dirty string-to-Elasticsearch-query parser, because writing this was easier than making sense of the nested query_string_query discussion. It probably has a bunch of errors and limitations, but it seems to work just fine for my needs.

Supported formats:

     Match _all fields: "value"
   Field specification: "field:value2"
             Wildcards: "*value*"
    Value greater than: "field > value"
Value greater or equal: "field >= value"
   Value less or equal: "field <= value"
       Value less than: "field < value"
          Nested field: "some_object.field:value"
                Phrase: "field:per hansen"

Clauses may be combined using " AND ".

Example:

client.search({
  index: 'files',
  type: 'file',
  body: {      
    from: 0,
    size: 10,
    query: autoquery.generate('file.size > 1024 AND file.name:*.pdf')      
  }
}).then(function(result) {
  console.log(result);
});

About

A quick-and-dirty "string to Elasticsearch query" parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published