# Match list in list

**URL:** <https://discuss.elastic.co/t/match-list-in-list/147489>\
**Category:** Elasticsearch\
**Created:** [September 6, 2018, 4:12am UTC](https://discuss.elastic.co/t/match-list-in-list/147489 "2018-09-06T04:12:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aashishgahlawat](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@aashishgahlawat](https://discuss.elastic.co/u/aashishgahlawat)\
**Post date:** [September 6, 2018, 4:12am UTC](https://discuss.elastic.co/t/match-list-in-list/147489/1 "2018-09-06T04:12:28Z")

</div>

I have my `apriori` result save on `elasticsearch` index as:

```
index | antecedents | consequents ...other fields
1 | [1,2] | [8]
2 | [1] | [55]
3 | [82] | [8,99]

```

Now I want to retrieve `consequents` if antecedent match:  
`[1,2]` or related i.e. using `match` rather than `term` (not match exactly)  
  
and the output shall be `[[8],[55]]` ordered by `score` of match

I want to get them form pandas or python query, what I am doing by now is:

```
from elasticsearch import Elasticsearch
from pandas.io.json import json_normalize
res = es.search(index="index_name", body={ "query": {"match_all": {}}})
df = json_normalize(res['hits']['hits'])

```

This is how I am by now retrieving records, I need the `elasticsearch query` to do so!  
Also I looked at: [Similar ES question](https://discuss.elastic.co/t/partial-list-of-words-match-in-documents/24042), but I here want the field and not includes

The documents are like:

```
{
"_id": 1, 
"antecedents": [1,2]
"consequents": [8]
...other fields
}
```

---

<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:** [October 4, 2018, 4:12am UTC](https://discuss.elastic.co/t/match-list-in-list/147489/2 "2018-10-04T04:12:29Z")

</div>

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