nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.53k stars 491 forks source link

[Question] Index whole String but store part of it? #261

Closed bphenriques closed 2 years ago

bphenriques commented 3 years ago

Hello! 👋

Given a document:

{
   "id": 32424324,
   "title": "title",
   "content": "quite large content"
} 

Is it possible to index both fields and prune.content to, for example, 90 characters (as I only need to provide a small preview of the content) to optimize the store? As of now I can get by having an additional field preview which is a truncated version of content :)

Thank you for the amazing project 🙇

ts-thomas commented 2 years ago

What you can do ist create an index and do not use builtin store. Instead after adding the object to the index prune the specific data field and push data objects manually to your own store object by using the ID as key. when getting back the results from the search you can just use arr.map(id => store[id]) to enrich results (when needed).