# How specify kstem in a query

**URL:** <https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729>\
**Category:** Elasticsearch\
**Created:** [April 9, 2017, 10:24pm UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729 "2017-04-09T22:24:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![witchlightning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/witchlightning/32/71962_2.png) [@witchlightning](https://discuss.elastic.co/u/witchlightning)\
**Post date:** [April 9, 2017, 10:24pm UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/1 "2017-04-09T22:24:43Z")

</div>

I'm using c# and am building a query similar to what is shown below. I want to use a kstem filter. Anyone know the syntax for that?

public async Task ExecuteAsync()  
{  
var result = await client.SearchAsync(  
s =\>  
s.Type(typeEmployee)  
.Query(q =\>  
q.MatchPhrase(m =\>  
m.Field(f =\> f.About).Query("rock climbing"))  
));  
Result = result.Documents;  
}

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 9, 2017, 11:49pm UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/2 "2017-04-09T23:49:28Z")

</div>

You can specify the analyser to use on match type queries but usually you  
are better off using the analyzer configured on the field. If you want to  
use a different analyzer at index and query time you can use  
search\_analyzer. Usually you don't, but some analysis techniques call for  
it.

I don't know the C# syntax for changing the analyzer on the query though,  
sorry!

---

<div class="post-metadata">

**Author:** ![witchlightning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/witchlightning/32/71962_2.png) [@witchlightning](https://discuss.elastic.co/u/witchlightning)\
**Post date:** [April 10, 2017, 3:29am UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/3 "2017-04-10T03:29:38Z")

</div>

I did an

---

<div class="post-metadata">

**Author:** ![witchlightning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/witchlightning/32/71962_2.png) [@witchlightning](https://discuss.elastic.co/u/witchlightning)\
**Post date:** [April 10, 2017, 3:37am UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/4 "2017-04-10T03:37:46Z")

</div>

I looked into it a bit more and generally the analyzers and filters are defined in the index when the mapping is created as you say, and that's all I need. I'm new to elasticsearch. It would be nice to see a complete mapping statement with a stemmed defined in the index part.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 10, 2017, 4:06pm UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/5 "2017-04-10T16:06:51Z")

</div>

Maybe around [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-creation)?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 10, 2017, 4:07pm UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/6 "2017-04-10T16:07:04Z")

</div>

Like, I'm wondering where would be a good place to link it.

---

<div class="post-metadata">

**Author:** ![witchlightning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/witchlightning/32/71962_2.png) [@witchlightning](https://discuss.elastic.co/u/witchlightning)\
**Post date:** [April 10, 2017, 8:51pm UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/7 "2017-04-10T20:51:06Z")

</div>

Thanks. I have enough rope now. 🙂

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 10, 2017, 9:27pm UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/8 "2017-04-10T21:27:48Z")

</div>

No, no! I really did mean that I was going to add something to the page and was asking your opinion on where. Something like:

The example above created the mapping that looks like

```auto
example here

```

See the mapping section for how to set up the mapping prior to creating indices.

Or something like that.

---

<div class="post-metadata">

**Author:** ![witchlightning](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/witchlightning/32/71962_2.png) [@witchlightning](https://discuss.elastic.co/u/witchlightning)\
**Post date:** [April 11, 2017, 12:36am UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/9 "2017-04-11T00:36:07Z")

</div>

Okay. In [Lucene.Net](http://Lucene.Net) you add your documents to an index. When searching you load the index and create an analyzer for the fields you want to search on. The analyzer comes into play when searching the index.

The difference in elasticsearch, it seems to me, is the analyzer goes with the field, defined in a PUT command with the mapping.

On on the Index api page, separate out Indexing a document, which is really saving a document to an index that's already defined.

Then show the mapping PUT statement including indexing commands, like:

PUT crud\_sample  
{  
"mappings": {  
"Customer\_Info": {  
"properties": {  
"id": {  
"type": "long"  
},  
"name": {  
"type": "text",  
"index" : {  
"analysis" : {  
"analyzer" : {  
"my\_analyzer" : {  
"tokenizer" : "standard",  
"filter" : ["standard", "lowercase", "my\_stemmer"]  
}  
},  
"filter" : {  
"my\_stemmer" : {  
"type" : "stemmer",  
"name" : "light\_english"  
}  
}  
}  
}  
},  
"age": {  
"type": "integer"  
},  
"birthday": {  
"type": "date",  
"format": "basic\_date"  
},  
"hasChildren": {  
"type": "boolean"  
},  
"enrollmentFee": {  
"type": "double"  
}  
}  
}  
}  
}

But it appears that that doesn't work. So, I guess my question is how do I run this:

{  
"index" : {  
"analysis" : {  
"analyzer" : {  
"my\_analyzer" : {  
"tokenizer" : "standard",  
"filter" : ["standard", "lowercase", "my\_stemmer"]  
}  
},  
"filter" : {  
"my\_stemmer" : {  
"type" : "stemmer",  
"name" : "light\_german"  
}  
}  
}  
}  
}

---

<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:** [May 9, 2017, 12:48am UTC](https://discuss.elastic.co/t/how-specify-kstem-in-a-query/81729/10 "2017-05-09T00:48:14Z")

</div>

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