Skip to content

Commit

Permalink
Add custom analyzer to match parts of the words which include special…
Browse files Browse the repository at this point in the history
… chars

Add custom filter and analyzer
Add missing fields to mapping
Remove language configuration as it was conflicting with
custom analyzer config see
TYPO3GmbH/elasticorn#21
Allow searching by extension key (also by fragment
- analyze the extension key)
  • Loading branch information
tmotyl committed Feb 2, 2022
1 parent 9897062 commit 7d2b63b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
2 changes: 0 additions & 2 deletions config/Elasticorn/Elasticorn.yaml

This file was deleted.

14 changes: 10 additions & 4 deletions config/Elasticorn/docsearch/IndexConfiguration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ analysis:
typo3_stemmer:
type: stemmer
language: minimal_english
typo3_filter:
type: word_delimiter_graph
preserve_original: true
analyzer:
typo3_analyzer:
type: custom
tokenizer: whitespace
filter:
- lowercase
- asciifolding
- typo3_stemmer
tokenizer: standard
- lowercase
- asciifolding
- typo3_filter
- typo3_stemmer

13 changes: 12 additions & 1 deletion config/Elasticorn/docsearch/Mapping.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
snippet_id:
type: keyword
manual_title:
type: keyword
type: text
analyzer: typo3_analyzer
fields:
raw:
type: keyword
manual_type:
type: keyword
manual_version:
type: keyword
manual_language:
type: keyword
manual_slug:
type: keyword
fragment:
type: keyword
page_title:
type: text
analyzer: typo3_analyzer
rootline:
type: keyword
relative_url:
type: keyword
snippet_title:
type: text
analyzer: typo3_analyzer
snippet_content:
type: text
analyzer: typo3_analyzer
content_hash:
type: keyword
11 changes: 8 additions & 3 deletions src/Repository/ElasticRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function deleteByManual(Manual $manual): void
'must' => [
[
'term' => [
'manual_title' => $manual->getTitle(),
'manual_title.raw' => $manual->getTitle(),
],
],
[
Expand Down Expand Up @@ -190,7 +190,12 @@ public function findByQuery(SearchDemand $searchDemand): array
[
'query_string' => [
'query' => $searchTerms,
'fields' => ['page_title^10', 'snippet_title^20', 'snippet_content']
'fields' => [
'page_title^10',
'snippet_title^20',
'snippet_content',
'manual_title'
]
],
],
],
Expand Down Expand Up @@ -295,7 +300,7 @@ private function addAggregations(Query $elasticaQuery): void
$elasticaQuery->addAggregation($catAggregation);

$trackerAggregation = new Terms('Document');
$trackerAggregation->setField('manual_title');
$trackerAggregation->setField('manual_title.raw');
$catAggregation->addAggregation($trackerAggregation);

// $status = new Terms('Status');
Expand Down

0 comments on commit 7d2b63b

Please sign in to comment.