0

Problem: traversing through more than 10,000 results in elastic search for a search query.

Is there anyway we can search a specific item without traversing/retrieving whole elastic search database. I came across scrolling but that is a memory intensive task since it will fetch all the unnecessary data in my case.

  • your need to add more context to your question. Can you give us an example of which document you want to retrieve? Cause basically of course you can search for specific record in elasticsearch, its just that your query needs to be specific enough =) – Pierre Mallet Oct 03 '18 at 09:37
  • Hey Pierre, I have multiple repositories in my elastic-search data and i want to retrieve/scroll all data against one repository, lets say OrganizationSearchRepository that is composed off of Organization. I have successfully scrolled through "All" the documents in my elastic search but i need to just fetch record against this specific repository. I am using elastic search scroll API for that purpose. It returns all data in elastic search at the moment – ahmedwaleedmalik Oct 03 '18 at 12:07
  • Then you should add a filter to your query. What is discriminant data for Organization documents ? – Pierre Mallet Oct 03 '18 at 12:12
  • Can't figure out how to add that filter, currently i am using "matchAllQuery" from that API which returns all objects. I have tried term and typeQuery to retrieve data only valid against that particular class but its not working out – ahmedwaleedmalik Oct 03 '18 at 12:22
  • you should realllllly read the elasticsearch introduction before anything else https://www.elastic.co/guide/en/elasticsearch/reference/current/_the_search_api.html – Pierre Mallet Oct 03 '18 at 13:52

2 Answers2

1

In elastic search query use filter clause to filter out the specific document.

GET index/_search
 {
 "query": {
 "bool": {
  "filter": {
    "match":{
      "field":"value"
    }
  }
}
}
}
Siddu
  • 156
  • 7
0

From your question, i got the understand, you need the records on the basis of a specific field. So in that case, You can get results by hitting the elastic Db using the below Query:

GET /_search?q={FieldName}:{FieldValue}

Akash Roy
  • 398
  • 5
  • 11