matteodem / meteor-easy-search

Easy-to-use search for Meteor with Blaze Components
MIT License
438 stars 68 forks source link

multiple index search with ElasticSearch? #647

Closed meecect closed 2 years ago

meecect commented 4 years ago

I have created several indexes against different collections and used the multi index search capabilities with some success.

I would, however, like to 'combine' the results into one results page, with a single text input for search. As it is currently, each index has its own pager, sort options etc.

I know that I can combine them client side but that is not ideal for my use-case.

I thought a way around this might be to use ElasticSearch, so I set up elastic search and have the basics working, returning results from a single collection.

Is there a way to use Elastic search as a hack to get multiple collection searching in EasySearch? Meaning, could I create multiple indexes using an elastic search engine, but stuff more than one type of document in there, so that I can search across them?

The end result is i'd like a page of search results like:

search for 'blah blah'

results:

content: blah blah type: event

content: blah blah type: person

content: blah blah type: group

content: blah blah type: article

I'm open to other ways of achieving this...one thought I had was to create a special collection (an 'index collection'); that acts as a staging area for the easy search index, then in my meteor methods make sure that every time content is added, removed, or updated from a variety of collections, I stick a document in this 'index collection' for it (with an additional 'type' field), then create an easysearch index (either mongodb or elastic) against it so that I could have a union of search results across collections.

Since elastic search is made for storing that kind of typed document already I had hoped I could use the elastic search index as that 'index collection' itself, without having an interim collection.

My other thought was to somehow create a publish function that aggregated the cursors of several other collections and use that as the cursor to populate the easy search index, but I couldn't quite figure out a way to do that.

Any ideas or pointers would be helpful.

Also, I see there are a number of issues around the web where people are trying just to get the basic elasticsearch module working at all (problems mostly stemming from changes in recent elastic search versions). I think I have cracked that issue and could provide a writeup/docs if needed.

matteodem commented 2 years ago

The component methods might be of help for you.

I can't answer very detailed questions to app specific problems as I don't have time for that but I hope that the docs can be of help to you. If there's a specific bug or a feature that you'd like to add please create a new ticket for that.