I've an index structure where types are dates and each type has several documents. I want to get all documents present in type-1 but must be absent in type-2. As an example:
Type-1 ---> id list = [1,2,3,4,5,6]
Type-2 ---> id list = [2,3,7,8,9]
The query i'm looking for should return documents from type-1 only with id = [1,4,5,6] I'm using es-py client for the above purpose.
PS: I can always get documents matching type-1 and type-2 individually followed by iterating through both of them to get what i need. But this is a solution i want to avoid for sake of performance.
Edit 1: Someone on stackoverflow suggested me the below query:
but its not going to work as it'll give me all documents present in type-1 which do not have _type equal to Type-2. This is basically equivalent to giving all documents matching Type-1. This is not what i want.
Please read the problem statement carefully. I am not trying to do any manual stuff here. I don't have a list of IDs which i can supply in the query and get a not of it.
It looks like you are trying to get all the documents in one set of results (_type = Type-1) that are not present in another set (_type = Type-2). This is effectively a join, which Elasticsearch does not support. You will therefore need to perform 2 requests.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.