question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add AND operator for joining terms

See original GitHub issue

As 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:closed
  • Created 6 years ago
  • Reactions:13
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

8reactions
olivernncommented, Feb 19, 2018

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!

8reactions
hafffecommented, Jan 23, 2018

Any updates on this? would love to see this feature!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found