# Implementiing "Partial match anywhere"

**URL:** <https://discuss.elastic.co/t/implementiing-partial-match-anywhere/90054>\
**Category:** Elasticsearch\
**Created:** [June 20, 2017, 7:50am UTC](https://discuss.elastic.co/t/implementiing-partial-match-anywhere/90054 "2017-06-20T07:50:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Borsodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_borsodi/32/19290_2.png) [@David\_Borsodi](https://discuss.elastic.co/u/David_Borsodi)\
**Post date:** [June 20, 2017, 7:50am UTC](https://discuss.elastic.co/t/implementiing-partial-match-anywhere/90054/1 "2017-06-20T07:50:58Z")

</div>

Hi

I'm trying to do a partial match anywhere search over medical terminologies. I've created any index with a multi-filed mapping of ngrams AND standard tokens.  
Unfortunately I can't get a good relevance score in the case where a full word and an fragment is typed.

It seems that that full word+segment with AND operator is not a match on the standard index, but without the AND operator false positives come up (but otherwise the result ordering is pretty ok). If I use the AND operator, the standard/english query returns with a 0 and while there are no false positives, matching only one of the terms, the ordering becomes messed up.  
This is my latest try:

```
    "query": {
    "dis_max": {
        "queries": [{
            "multi_match": {
                "query": expr,
                "operator": "AND",
                "type": "most_fields",
                "fields": [field, field + ".std^4"]
            }
        },
            {
                "multi_match": {
                    "query": expr,
                    "type": "most_fields",
                    "fields": [field + ".std^4"]
                }
            }
        ]
    }

```

Is there a standard way to solve this issue? (I forgot to mention that I'm new to ES and only read half of the definitive guide so far)

---

<div class="post-metadata">

**Author:** ![David\_Borsodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_borsodi/32/19290_2.png) [@David\_Borsodi](https://discuss.elastic.co/u/David_Borsodi)\
**Post date:** [June 20, 2017, 8:56am UTC](https://discuss.elastic.co/t/implementiing-partial-match-anywhere/90054/2 "2017-06-20T08:56:12Z")

</div>

Experimenting further, it seems that splitting the expression to words and creating a bool-should for each of them increases the quality of the search results a lot. The false positives still show up though, but with lower relevance.  
Nonetheless I'd be interested in any advice to filter them out completely  
\> {

> ```
> "bool": {
> "should": [
> {
> "term": {
> "en.std": "neurological"
> }
> },
> {
> "term": {
> "en.std": "diso"
> }
> }
> ]
> }
> }
> 
> ```

---

<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:** [July 18, 2017, 8:56am UTC](https://discuss.elastic.co/t/implementiing-partial-match-anywhere/90054/3 "2017-07-18T08:56:22Z")

</div>

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