Is there something like Solr or Elasticsearch that can only be used on the client in Javascript?

We have a small data set and he would like to find it using a smart way to fill in an autocomplete input field. The user wants to search for one type of entity, but must be able to add attributes of related types.

Since our application is very industry specific, I will try to include the abstract question in a more relevant context:

Example : a user wants to select a certain type of fruit and can use many different characteristics of the fruit to find it. She can search for her name (apple), special types of the same fruit (golden delicious), localized versions (apfel, Ψͺفاح, pomme), but also other characteristics, such as food containing fruits (pandas, cider) or even full-text results search for his description.

Usually I would like to use something like solr or elasticsearch , but our data set is not very large with 4-5 related objects with a maximum of 200 elements each. In addition, it will remain very static, with several editorial additions every week. Therefore, we thought about using the browser data store to manage and search for some kind of index. The problem is that in our research we could not find anything that goes far beyond abstracting Web SQL or an indexed database .

Are there projects or libraries that do something like solr or elasticsearch and can be used on the client side for small datasets? We are looking for the following features.

  • Quick search
  • Pre-processing (tokenization, filtering ...)
  • Order
  • Rating, increase in requests

It should work with the latest browsers and a mobile, dumb reserve for other browsers (i.e. full-text search) acceptable

+6
source share
1 answer

IndexedDB With an incredibly cumbersome job, and I don't think that it will do what you want, without any changes.

WebSQL I use Chrome WebSql (sqlite) with full-text (FT3), and you can perform some preliminary queries with it, and it automatically weighs the results. eg:

table_ft3 structure = [id, name, description, pets]

and you can ask for "SELECT id FROM table_ft3 WHERE table_ft3 MATCH 'word1 word2 wordfuzzy * -notme + required name: john edwar * mary pets: dog cat'"

This, however, is limited to Chrome. On a table of 560 thousand lines of 12 words each very quickly, 10 ms or less.

JSLinq - http://jslinq.codeplex.com/ This is good for large datasets, storing everything in memory, it's ridiculously fast, but I don't think it has any kind of extended weight. This has the added benefit of allowing you to write your own complex query functions.

JSII - http://karussell.wordpress.com/2010/11/02/jsii-full-text-search-in-1k-loc-of-javascript/ It uses Lucene style weighting, and on 20 kg rows it comes at 50 ms, which is not big, but probably good enough for your data.

+3
source

Source: https://habr.com/ru/post/918190/


All Articles