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

Getting Fields as output along with the Index Id from the search. #175

Closed prashant1k99 closed 4 years ago

prashant1k99 commented 4 years ago

Is there a way to get the entire object as the output of the search result so that we don't have to save the data again outside of the flexsearch for getting the remaining values of the result.

And also saving the processing time for again iterating through the entire array for the id, if the data passed is complex. Like:


[
  {
    "_id": "5e9befa44471b8b7cd1271d1",
    "title": "Consectetur cillum commodo laboris fugiat veniam sunt adipisicing aute id ea culpa esse do.",
    "url": "http://placehold.it/32x32",
    "status": "public",
    "description": "Consectetur eu ipsum ut consequat reprehenderit deserunt Lorem officia culpa quis nostrud. Sit sit minim non veniam eiusmod occaecat. Dolore duis tempor irure aliqua enim magna laboris labore dolor. Culpa et sit anim minim labore. Non aute occaecat laborum tempor consequat sunt enim velit ea elit anim.\r\n",
    "tags": [
      "cupidatat",
      "nostrud",
      "nulla",
      "tempor",
      "ut",
      "enim",
      "excepteur"
    ],
    "timestamp": "2018-04-05T08:52:15 -06:-30"
  },
  {
    "_id": "5e9befa4ebded827393cefa6",
    "title": "Magna deserunt eiusmod voluptate culpa adipisicing.",
    "url": "http://placehold.it/32x32",
    "status": "public",
    "description": "Esse pariatur nisi ullamco elit ex laboris occaecat quis irure ipsum adipisicing minim anim. Consequat sit enim nisi incididunt velit. Est duis consectetur aliquip aliquip dolore minim ex tempor cillum qui. In eu ea ut est incididunt cupidatat incididunt incididunt reprehenderit cupidatat ullamco enim. Cupidatat Lorem ullamco in in sunt dolore mollit fugiat pariatur.\r\n",
    "tags": [
      "Lorem",
      "culpa",
      "nostrud",
      "anim",
      "anim",
      "labore",
      "mollit"
    ],
    "timestamp": "2015-09-10T05:15:20 -06:-30"
  },
...
]

Now lets say if we set the id of the data as the _id then, we can't simply get the resutl with:

var result = data[_id]

but the alternative for that is we can add another id for the index purpose, but it will increase the data size for flexsearch as well.

So it would be better if we get the remaining fields as the result from the search.

prashant1k99 commented 4 years ago

https://github.com/nextapps-de/flexsearch/issues/36#issuecomment-462740454