itemsapi / itemsjs

Extremely fast faceted search engine in JavaScript - lightweight, flexible, and simple to use
Apache License 2.0
350 stars 41 forks source link

Asking for help, search nested objects #108

Closed GonzalesDK closed 2 years ago

GonzalesDK commented 2 years ago

Hi I kindly ask for some help regarding searching objects. All the examples I have seen, assume that the item list has a structure similar to : var rows = [ {

"runtime": 142,
"country": [
  "USA"
],
"tags": [
  "prison",
  "wrongful imprisonment",
 ], .....

Then aggregation filters (and more) aggregations: { tags: { title: 'Tags', size: 10, conjunction: true }, Now this makes it possible to search tags for the values, but imagine that tags in rows would not be a list of string but a list objects { desc: "A super tag", created: "some date" }

How would you filter that ?

Thank you regards Tommy

cigolpl commented 2 years ago

Hey @GonzalesDK,

Personally I'd preprocess your data so it has a flat structure. I'd keep the flat array only for searching and I'd keep the separate array with nested object for displaying in your layout / views. Imo this is the common practice even with more sophisticated engines like Elasticsearch (different search data in ES and original nested / relational data in PostgreSQL or MySQL)

GonzalesDK commented 2 years ago

@cigolpl Thanks a lot, was doing something like that, just wanted to make sure that there wasn't some other way of doing it. Thank you

SergeyRe commented 2 years ago

i have the same problem with realizing custom facet values ordering - something like with fields value as objects {name: USA, sortcode:1} The story looks the same not only with elastic , but Algolia and Meilisearch +Typesense. May be to solve it is the way to make advantage for itemsjs ?

dgastudio commented 1 year ago

Hello! first of all, thank you for the awesome project. But, i'm agree with previous comments

you are already using lodash as dependency, it will be great if you will implement GET function of lodash for nested props of json objects,