Using ElasticSearch to perform complex queries and then retrieve the IDs for MySQL queries

3

I'm thinking of the following idea: Use the ElasticSearch features to do complex searches instead of directly querying MySQL using many where . If I were to use MYSQL I would have to create many indexes.

So when I give insert to my table I also go through the ElasticSearch log, I would do this complex query in ElasticSerch, and I would get the id 's to query MySQL for example:

SELECT * FROM table WHERE id IN (1,4,8,9,21,54,87,...)

Would this be feasible?

    
asked by anonymous 30.07.2015 / 22:46

1 answer

3

I use this form to make my queries because the relevance is much greater and faster with the ids in hand I make the query in mysql to return a result:

WHERE produtos.id_produto IN (id1,id2,id...) 
ORDER BY FIELD(id1,id2,id...)

Use order by field so you do not lose elasticsearch score ordering.

    
20.01.2016 / 19:27