# Cross field serch problem

**URL:** <https://discuss.elastic.co/t/cross-field-serch-problem/254360>\
**Category:** Elasticsearch\
**Created:** [November 5, 2020, 7:39am UTC](https://discuss.elastic.co/t/cross-field-serch-problem/254360 "2020-11-05T07:39:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![squareEngine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/squareengine/32/70002_2.png) [@squareEngine](https://discuss.elastic.co/u/squareEngine)\
**Post date:** [November 5, 2020, 7:39am UTC](https://discuss.elastic.co/t/cross-field-serch-problem/254360/1 "2020-11-05T07:39:19Z")

</div>

Hi  
I'm trying to implement search functionality in our project using Nest. I have following query:

```auto
   query
	.Bool(must => must
			.Filter(m => m
				.MultiMatch(qs => qs
					.Type(TextQueryType.CrossFields)
					.Lenient(true)
					.Fields(fields => fields
						.Field(item => item.Username)
						.Field(item => item.Name)
						.Field(item => item.Surname)
						.Field(item => item.FavColor)
						.Field(item => item.Description)
						.Field(item => item.ClientNumber)
						.Field(item => item.Code)
						.Field(item => item.Options)
						.Field(item => item.Equipment)
						.Field(item => item.Year)
						.Field(item => item.Status))
					.MinimumShouldMatch(MinimumShouldMatch.Percentage(100))
					.Query(filters?.SearchText ?? string.Empty)

```

Fields have diffrent analyzers:

- Edge-Ngram
- Ngram
- Keyword

When I enter the search query, f.e. **John Redling** , I want get only the documents, that have all words from search phase, but each word can be found in separate fields, for example user with name John o Johnny(edge-ngram analyzer) and surname starting with Redling.  
My problem is, that currently, having ngrams make this difficult. It the exmple above Redling produces ngrams: red, edl, dli, etc. I set MinimumShouldMatch to 100%, but still it can find red in color and ling in different field and it's 100%, but it's not document i'm looking for.  
Is there a better way to implement it?

---

<div class="post-metadata">

**Author:** ![squareEngine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/squareengine/32/70002_2.png) [@squareEngine](https://discuss.elastic.co/u/squareEngine)\
**Post date:** [November 5, 2020, 9:23am UTC](https://discuss.elastic.co/t/cross-field-serch-problem/254360/2 "2020-11-05T09:23:56Z")

</div>

I ended up increasing maxgram value to 10, keeping mingram at 3. It doesn't sovlve the problem entirely, but probability of having false positive results is very low.

---

<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 3, 2020, 9:24am UTC](https://discuss.elastic.co/t/cross-field-serch-problem/254360/3 "2020-12-03T09:24:06Z")

</div>

Closed on December 3, 2020, 9:24am UTC

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