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

**URL:** <https://discuss.elastic.co/t/match-specific-element-with-specific-id-return-1-or-0-dsl/95964>\
**Category:** Elasticsearch\
**Created:** [August 5, 2017, 6:31am UTC](https://discuss.elastic.co/t/match-specific-element-with-specific-id-return-1-or-0-dsl/95964 "2017-08-05T06:31:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akanksha\_Toshniwal](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Akanksha\_Toshniwal](https://discuss.elastic.co/u/Akanksha_Toshniwal)\
**Post date:** [August 5, 2017, 6:31am UTC](https://discuss.elastic.co/t/match-specific-element-with-specific-id-return-1-or-0-dsl/95964/1 "2017-08-05T06:31:38Z")

</div>

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'])
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 2, 2017, 6:32am UTC](https://discuss.elastic.co/t/match-specific-element-with-specific-id-return-1-or-0-dsl/95964/2 "2017-09-02T06:32:03Z")

</div>

Closed on September 2, 2017, 6:32am UTC

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