Problem/Motivation
Currently the module doesn't support fuzziness:
https://www.elastic.co/guide/en/elasticsearch/reference/5.6/common-optio...
Fuzziness can be added to queries to return results within a configured Levenshtein Edit Distance. This has the effect of returning misspellings in either the search keywords or the content, and is generally very useful.
Proposed resolution
Add support for fuzziness.
Remaining tasks
- Add to the Elasticsearch backend configuration to specify default fuzziness params, including toggleing it on/off.
- Would be nice to specify fuzziness params as part of a view configuration.
- Apply fuzziness params at query time, first from the view, then from defaults for backend, then default to off.
User interface changes
Added configuration form elements for fuzziness params in the Backend configuration and the view if possible.
API changes
Fuzziness is made available in the query builder.
Data model changes
None.
Comments
Comment #2
m4oliveiThe elasticsearch_connector module currently performs full text searches using the
query_stringquery. This query type makes it tricky to add fuzziness to, as you have to include a tilde against each keyword. For example, let's say we want fuzziness, our search term is the poorly spelled "qiuck borwn fxo".With a Match Query we could do:
And that would give us the result we want, just by adding
fuzziness: auto. With a Query String query, we would need to do:Here note how we need to add the tilde to each of the search keys. Which isn't horrible, but leads me to ask, why does the module make everything into a
query_stringquery.I'm very new to Elastic search, so first hoping to learn more, before jumping in and making changes like this.
Comment #3
m4oliveiHumm, I think I'm coming to an understanding that elasticsearch_connector uses query_string, b/c the Lucene query language offers the flexibility needed to handle the
QueryInterface::getKeys()definition (which can include conjunctions and negations).It's probably better to fit fuzziness support into the existing query_string queries then?
Comment #4
m4oliveiWonder if this would be a nice addition:
https://github.com/makinacorpus/php-lucene-query
Comment #5
skek commentedNot quite sure about the last one because elasitcsearch is providing all needed and don't think it will be good idea to use lucine queries directly.
Regarding the query, it was quering_string because at the time of development it was fastes implementation, but not best.
In future, we should have bool query with must, should and should_not causes in combination with other queries in order to achieve maximum relevancy so definitely a big area of improvement in query builder. I have a task to abstract this but it is still in the pipeline
Comment #6
m4oliveiYeah to be clear the library I linked is just a small API for building up the query_string query parameter specced here: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/query-dsl-qu.... It's a structured approach to building these strings vs. the string concatenation style approach already in the elasticsearch_connector module. It supports all the conjunctions, fuzziness, negations, etc.
I threw together a WIP:
https://github.com/nodespark/elasticsearch_connector/pull/19
This is rough for a couple reasons, first being that I needed to fork the library to get un-distanced fuzziness for terms.
Let me know what you think?
Comment #7
m4oliveiThe upstream library change was merged and a new release put out. I've updated the PR for this ticket. I think it's ready to rock.
https://github.com/nodespark/elasticsearch_connector/pull/19
Comment #8
juampynr commentedThe pull request at https://github.com/nodespark/elasticsearch_connector/pull/19 works fine and covers many scenarios.
@skek, what do you think?
Comment #10
skek commented