Skip to content
This repository has been archived by the owner on May 14, 2019. It is now read-only.

Permit choose between must and filter #6

Open
sevdog opened this issue Apr 13, 2018 · 3 comments
Open

Permit choose between must and filter #6

sevdog opened this issue Apr 13, 2018 · 3 comments

Comments

@sevdog
Copy link

sevdog commented Apr 13, 2018

As of now all queries are converted into must.

However someone could want to use filter queries (to not spend time calculating scrores).

There should be an option or a parameter to choose between must and filter when calling the parser.

@sudo-suhas
Copy link
Collaborator

Hey @sevdog, I was under the impression that this package isn't really being used by anyone so I haven't really been maintaining it much. However, I am happy to discuss improvements. Do you have any suggestions for how the filter query would be specified?

@sevdog
Copy link
Author

sevdog commented Apr 15, 2018

Its fun, I was looking for a library that may allow me (and my users) writing more easily queries for Elasticsearch, without using Lucene syntax. This because in many cases we do not need Elasticsearch to calculate result score (which is done with Lucene Query String )

Then I found this library and got a try. It is really more simple to write a query with it. However it uses must Boolean clause which calculates score.

Based on what I have found in the code, there are two points where main changes are needed:

  1. muto-parser
  2. query-builder-def

IMO when calling mutoParser.parse there may be an additional option which will contain the choice between must/filter. This option may be delivered to queryBuilderDef as a parameter. Also this parameter will be set in parse, using must as default.
Data validation will take place inside mutoParser.parse to provide consistency.

If I can find some free-time I may try to produce a PR for this, but I never worked with PEGjs and I must learn if my changes may also impact how it works.

@sudo-suhas
Copy link
Collaborator

@sevdog A PR would be very welcome 😄.

The changes would need to be done in the PEG.js definition file which is used to generate the muto-parse.js file(npm run build:parser).

Right now, notAnalysedFields are passed in to the parse function as a parameter and used in StrEqCondition. You can use this as a reference if required.

For the most part, you would only need to tweak the JS embedded in PEG.js definition file(see example). If you wish to override any of the implementation present in query-builder-def.js, you can use a muto.config.js file. See readme for more details on customisation - https://github.com/booleanapp/elastic-muto#customisation/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants