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

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.

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

Untitled
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?

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.

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.

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, 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.

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.

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