Search Controller
Introduction
The search controller. AdmiralCloud's search is based on OpenSearch/ElasticSearch (ES). You can use ES query language (DSL). Some limitations might occur and some fields/properties might not be allowed to use or return unexpected results as we sanitize and enhance every search request to ensure security of the call.
If you want to create complex applications it is highly recommended to talk to our engineering team.
Search Intelligence & Language Support
Our search engine automatically handles various input formats and languages to provide the best possible results:
Multilingual Text Processing
- German Umlauts/Special characters: Searches for "Münster", "Muenster" return identical results, but search for "Munster" (ascii-folding) does not! German ß is treated the same as "ss"
- Accented Characters: Searches for "café" and "cafe" work interchangeably in all other languages (ascii-folding)
- Compound Words: German compound words are automatically decomposed (e.g., "Fußballspiel" matches documents containing "Fußball", "Ball", or "Spiel"). But not all compound words can be decomposed due if grammar rules can not be (fully) applied or the word is not found in the dictionary we use (standard open source German dictionary for OpenSearch)
Fuzzy Search & Error Tolerance
- Typo Correction: Minor spelling mistakes are automatically corrected
- Flexible Matching: The system finds relevant results even with incomplete terms
Language Priority
We search in both universal language fields and the user's preferred language. The user's language results receive higher relevance scores.
Score Understanding
- matched_queries field shows which search criteria matched, helping debug relevance
- Higher scores indicate better matches
- Language-specific matches receive boosted scores
- Full matches are scored higher than part matches
Search Performance Tips
Optimizing Search Queries
- Use noAggregation: true if you don't need facets – significantly improves performance
- Limit size to what you actually need (default: 50, max: 1000)
- Use sourceFields to return only required fields
- Consider operation: "count" if you only need result counts
Pagination Best Practices
⚠️ Important: When using search with size and from, you might run into a situation where not all documents for the search or even duplicates (on the next page/batch) are returned. It you want to scroll through results, it is recommended to use scroll contexts instead of size and from.
Elasticsearch uses Lucene’s internal doc IDs as tie-breakers. These internal doc IDs can be completely different across replicas of the same data. When paging search hits, you might occasionally see that documents with the same sort values are not ordered consistently.
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html
Default search
The default search parameters, like aggregations or searchableFields can be found using Misc Controller. The searchableFields are those the standard search uses.
Basic Search
Enable basic search to search in field "relevantWords". Relevant words is a combined field from container_name and tags.
Customized search experience
You can customize the search experience on a customer or user base. You can define other aggregations (as long as they are members of the default aggregations set) and you can customize which fields you want to be searched and what boosting they should have.
See Customized search experience for an example
Examples for searches
Basic/Simple search
`// search for the given search term in all default fields (usually container_name, container_description)
{ "searchTerm": "my search term",
}`
Complex searches
In order to work with complex searches, it is highly recommended to make yourself familiar with OpenSearch/ElasticSearch query DSL.
`// search for huset (swedish for house) but search only videos and boost hits in swedish by factor 100.
{ "size":30, "languages":[ { "lang":"sv", "boost": 100 } ], "searchTerm":"huset", "query":{ "bool":{ "filter":[ { "terms":{ "type":[ "video" ] } } ] } }
}`
Special searches
`// color search
{ "searchTerm":"55,66,204", "field":"colorSearch", "colorSearchParams":{ "diff_ab":20, "diff_l":10 }
} // geo search
{ "searchTerm":"47.49, 19.05, 10", "field":"gps"
}`