# How do I implement exact full text search on an index created by fscrawler

**URL:** <https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617>\
**Category:** Elasticsearch\
**Created:** [November 5, 2019, 1:18pm UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617 "2019-11-05T13:18:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denn](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Denn](https://discuss.elastic.co/u/Denn)\
**Post date:** [November 5, 2019, 1:18pm UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/1 "2019-11-05T13:18:44Z")

</div>

I have an index that I created with fscrawler... How do I do a full text search on the content so that it matches words exactly even the cases?

```
if ($q2 == '') {
 $params = [
'index' => 'trial2',
    	'body' => [
		'query' => [
			'match_query' => [
				'content' => $q
							]
				]
			]
		];

		$query = $client->search($params);
		$data['q'] = $q;
	}

```

The query does not have exact matches.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 5, 2019, 2:20pm UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/2 "2019-11-05T14:20:52Z")

</div>

You need to change the analyzer in the mapping for that.  
May be look at [https://fscrawler.readthedocs.io/en/latest/admin/fs/elasticsearch.html#creating-your-own-mapping-analyzers](https://fscrawler.readthedocs.io/en/latest/admin/fs/elasticsearch.html#creating-your-own-mapping-analyzers)

---

<div class="post-metadata">

**Author:** ![Denn](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Denn](https://discuss.elastic.co/u/Denn)\
**Post date:** [November 6, 2019, 5:53am UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/3 "2019-11-06T05:53:05Z")

</div>

![Untitled](https://us1.discourse-cdn.com/elastic/original/3X/c/c/cc10615234ea6a4b1885fea16b5400d6580e7db7.png)  
Something like that right? .. just that?

because when I make that change the search query now doesn't get the previous hits I was getting.

and does that mean if there are words not in English they will not be analyzed?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 6, 2019, 7:13am UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/4 "2019-11-06T07:13:27Z")

</div>

> [@Denn](#):
>
> and does that mean if there are words not in English they will not be analyzed?

No. The `english` analyzer is always applied. Have a look at the `_analyze` API to see how the text is analyzed with the analyzer you are using.

---

<div class="post-metadata">

**Author:** ![Denn](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Denn](https://discuss.elastic.co/u/Denn)\
**Post date:** [November 6, 2019, 8:25am UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/5 "2019-11-06T08:25:11Z")

</div>

> [@dadoonet](#):
>
> `_analyze`

where is this located?

I have also tried to change the tokenizer to keyword but it gives the same results as before.

[Just to explain, essentially what I am trying to do is make a full text search (which runs fine with the default mapping) but I want to implement an exact match if the user puts the search query between quotes, (the query could be a word of phrase) maintaining case sensitivity]

sorry I am really struggling to understand.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 6, 2019, 10:53am UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/6 "2019-11-06T10:53:23Z")

</div>

> [@Denn](#):
>
> where is this located?

> **[Analyze API | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html)**

So before thinking of modifying things in FSCrawler, you need to find the right analyzers, mapping for your use case.

The easiest way is to start with some sample minimalist documents (just one field) and play around with the API.

Once you have a full script which reproduces the problem as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21), share it here. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![Denn](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Denn](https://discuss.elastic.co/u/Denn)\
**Post date:** [November 6, 2019, 1:39pm UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/7 "2019-11-06T13:39:59Z")

</div>

I am having a challenge implementing a search analyzer for the content field so that it depends on the query for the results i.e the query is a string and if it is without quotes, it gives all results not considering cases (currently working).. but if you have the query between quotes, then it gets only exact matches (could be a word or phrase).

I tried not analyzing the field but that doesn't work. Neither does normalization.

```
  "content": {
    "type": "text",
    "index": true
  },

```

Do I use match\_query or term?

```
	if ($q2 == '') {
		$params = [
			'index' => 'trial2',
			'body' => [
				'query' => [
					'filter' =>[
						'term' => [
							'content' => $q
						]
					]
				]
			]
		];

		$query = $client->search($params);
		$data['q'] = $q;
	}

```

I truly appreciate your feedback .. kindly guide me on the steps, something like changing the analyzer so that I can do both partial and exact matches depending on the query.

---

<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 4, 2019, 1:40pm UTC](https://discuss.elastic.co/t/how-do-i-implement-exact-full-text-search-on-an-index-created-by-fscrawler/206617/8 "2019-12-04T13:40:03Z")

</div>

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