Add AND operator for joining terms
See original GitHub issueAs was mentioned in #261 lunr.js currently doesn’t support joining search terms with AND
. It can has interface similar to what Elasticsearch has. You specify what is default operator (OR
or AND
) and the terms are joined with the specified operator. Otherwise it can look similar to this:
index.query(function(q) {
q.terms('AND')
.term('hello', fields: ['field1'], boost: 10)
.term('world', fields: ['field2'], boost: 1);
q.terms('OR')
.term('term1')
.term('term2');
});
Or with .search()
it can look like this:
index.search('term1 term2', { operator: 'AND'} )
Or more sophisticated with new modified query syntax:
index.search('term1 AND term2 OR term3')
What do you think?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:13
- Comments:20 (5 by maintainers)
Top Results From Across the Web
SQL Joins with Comparison Operators - Mode Analytics
This lesson of the SQL tutorial for data analysis covers using comparison operators with SQL joins, which is especially helpful for defining date...
Read more >Combining and Negating Conditions with AND, OR, and NOT
You can use the AND and OR operators to combine two or more conditions into a compound condition. AND, OR, and a third...
Read more >3 Operators, Functions, Expressions, Conditions
You can use an arithmetic operator in an expression to negate, add, subtract, ... Indicates that the preceding column is the outer join...
Read more >Left and Right Joins Using the Plus (+) Sign in Oracle - Chartio
Learn how to use left and right joins using the plus sign in an Oracle database. Oracle allows queries to be generated that...
Read more >Combining terms with Boolean Operators (AND, OR, NOT)
Boolean Operators are specific words used to combine concepts or keywords to improve the chances of finding relevant information. The most commonly used...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for the lack of updates on this (and other) issues, my son was born at the end of last year so I haven’t had a lot of free time recently 😅
I did push a branch with the changes to support this, its all there apart from the additions to the search string parser. So you can programatically construct queries with
lunr.Index#query
to test it out.I’ll put together a WIP PR with a bit more detail to help people try out what is there currently, getting some feedback would be good. Thanks for the patience on this feature too!
Any updates on this? would love to see this feature!