Match Specific element with specific id (RETURN-1 or 0)- DSL


(Akanksha Toshniwal) #1

If tags:[a,b,c,d....k], tags:[x,y,a,....b] are the fields,
I want to perform search in DSL (python), if tags:[a] is found, It should returns all id's which satisfies the search, then I want to search tags:[b] on same ids (to check if they are coming together), then tags:[c] then so on..if not found together it should return zero.
I am writing following code:

for l in range(0, ver):
s=Search(using=es,index="trial")
.query("match",tags=lis[+int(l)] )
responses=s.execute()
print responses
print ("")
if responses:
for hit in responses['hits']['hits']:
doc = {
'tags': lis[+int(l)]
}
# w=[hit['_id']]
#print w
#res = es.search(index="trial", doc_type='modi',id=w[0], body=doc)
or
res=es.search(index="trial",doc_type='modi',id=hit['id'], body=doc)

                    print res
                    print ("")
                    if res:
                            print (res['_source'])

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.