# Matching multiple phrases to specific fields in Nest

**URL:** <https://discuss.elastic.co/t/matching-multiple-phrases-to-specific-fields-in-nest/256124>\
**Category:** Elasticsearch\
**Created:** [November 20, 2020, 1:47pm UTC](https://discuss.elastic.co/t/matching-multiple-phrases-to-specific-fields-in-nest/256124 "2020-11-20T13:47:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adiksl](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@adiksl](https://discuss.elastic.co/u/adiksl)\
**Post date:** [November 20, 2020, 1:47pm UTC](https://discuss.elastic.co/t/matching-multiple-phrases-to-specific-fields-in-nest/256124/1 "2020-11-20T13:47:19Z")

</div>

I have built an application in C# which searches my Elasticsearch documents and this all works fine using this code....

```auto
List<AuditLog> resultsList = Client.SearchAsync<AuditLog>(s => s
    .From(0)
    .Take(noRows)
    .Query(q => q
        .Bool(b => b
            .Must(mu => mu.MatchPhrase(mp => mp.Field("audit_Event").Query(auditEvents)),
                mu => mu.Match(ma => ma.Field(field).Query(value))
             )
          )
     )).Result.Documents.ToList();

```

This all works fine but there is a new requirement to search the audit\_Event field against multiple phrases, such as "User Login", "Add Employee" etc

I have found reference to multi\_match but this appears to be more related to searching across multiple fields rather than multiple values in one field.

Following discussions below, TermQuery would seem to do the job but doesn't return any values. Any ideas?

```auto
QueryContainer queryAnd = new TermQuery() { Field = "audit_Application", Value = "MyApplication" };
QueryContainer queryOr = new TermQuery() { Field = "audit_Event", Value = "Employee Inserted" };
queryOr |= new TermQuery() { Field = "audit_Event", Value = "Employee Updated" }; 
QueryContainer queryMain = queryAnd & queryOr;

resultsList = Client.SearchAsync<AuditLog>(s => s
    .From(0)
    .Take(noRows)
    .Query(q => q
        .Bool(b => b
            .Must(queryMain)
        )
    )).Result.Documents.ToList();

```

I've also checked the two queries using Kibana, the first one returns data but the second one doesn't, and am now wondering if it a problem with how the data is indexed....

```auto
GET auditlog/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "audit_Event": "Employee Updated"
          }
        },
        {
          "match_phrase": {
            "audit_Event": "Employee Inserted"
          }
        }
      ]
    }
  }
}

GET auditlog/_search
{
  "query" : {
    "terms": {
        "audit_Event": ["Employee Updated","Employee Inserted"]
    }
  }
}

```

---

<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:** [December 18, 2020, 1:47pm UTC](https://discuss.elastic.co/t/matching-multiple-phrases-to-specific-fields-in-nest/256124/2 "2020-12-18T13:47:26Z")

</div>

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