简体   繁体   中英

using elasticsearch with mongodb

Been looking into creating a faceted search with elasticsearch

my data will be in mongodb

quite new to this but am i right in assuming and handle the normal queries with the database that pull back results but use data returned(in JSON)with elasticsearch for the faceted queries. sorry if it sounds a weird question cant get my head round it

Elasticsearch requires you to index the data in your database into Elasticsearch. This allows Elasticsearch to build an inverted index of all your data and thus making it searchable.

Essentially what you will end up with is a duplication of your data in Elasticsearch, however in a different form. To index this data a plugin has been developed to create a river from MongoDB to Elasticsearch located here .

Once you have started Elasticsearch, it exposes an end point where you can send queries in the form of Elasticsearch' Query DSL language. There you can perform facets on your data, like so -

{
  "size": 0,
  "query": {
     "match_all": {}
   },
   "facets": {
     "tag": {
       "terms": {
         "field": "name",
         "size": 6
       }
     }
   }
 }

Any more questions I can clarify these for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM