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.

Advanced query example?

See original GitHub issue

I’m trying to use FlexSearch for building a search that acts a lot like the lucene language, so support for logical operators (using either AND, NOT or +, - respectively as well as OR), quotes/exact phrase match (“foo bar” won’t match the text “bar foo”).

From the README’s supported features table it looks like FlexSearch can do that, but I couldn’t seem to get it to work using even a “wasteful” configuration, as well as a basic query:

const index: Index<string> = FlexSearch.create({
  tokenize: 'full',
  encode: 'extra',
  stemmer: false,
});

index.add(1, 'foo');
index.add(2, 'bar');
index.add(3, 'foo bar');
index.add(4, 'bar foo');

const values = index.search([
    { query: 'foo' },
    { query: 'bar' },
]); // values is an empty array

If I use the string overload of search: index.search('foo bar') it does find id 3 and 4, but how can I specify that only one of them is required for example, or that the I want the full query as a phrase (i.e. id 3 is valid, 4 is not).

So, a couple of questions:

  1. Am I missing something?
  2. Is what I want to do even possible with FlexSearch? If so, how can I achieve that? Ideally I’d just configure the operators in the create() call, and then search() can parse it automatically based on that.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
bengrycommented, Nov 27, 2019

@ts-thomas I didn’t see that issue on my previous search. Too bad it’s not supported. I voted for it there anyway, and this issue and upvotes and attention it received strengthens that it’s a needed (wanted) feature 😃. I hope it’s taken into account as a feature request in a future release. This is what we wanted to use Flexsearch (or others) for.

2reactions
ts-thomascommented, Jun 28, 2021

Please change over to the version >= 0.7.x, thanks a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TOP-70 Most Important SQL Queries in 2022 - ByteScout
The following are some database queries examples that deal with creating tables, in a bit more advanced fashion. Create a table with a...
Read more >
How to Do Advanced Queries in MySQL - Universal Class
Let's take the following query as an example: SELECT COUNT(customer_id) FROM Customer; The above statement counts the number of customer records in your ......
Read more >
Complex SQL Query Example - Daily Order Analysis
Introduction. This article is a case study on writing a complex query on an SQL database. We start with a set of database...
Read more >
Complex SQL Queries Examples(90% ASKED IN Interviews)
Complex SQL Queries · 1.Query to find Second Highest Salary of Employee?(click for explaination) · Answer: · 2.Query to find duplicate rows in...
Read more >
SQL Advanced Query Samples for Dummies - Overview
The purpose of this application is to present practical examples of using advanced SQL commands for your daily life, such as: SQL Tips...
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