Search
Litium uses Lucene as the underlying search engine. This article explains the general concepts and things to watch out for. Detailed code examples are given in articles under each module.
Developers are not required to know about Lucene when implementing functionality based on search, but some key observations should be kept in mind.
- When a change is made in an entity, it will take a short amount of time for the search engine to index the changes. Therefore, if you search immediately after the change, it might not result in a successful hit.
- Searching has better performance when compared to iterating through a large collection to find an item. For example, if you would like to find all articles with article numbers starting with "001", it is much faster to search.
- When building search, pay attention to the Lucene search text syntax. For example, '*' at the end of a string means a pattern match, with any number of ending characters.
- Take language into account when searching, since certain property values might be language dependent. However, if you are searching for a language independant field, you may use the default language.
- After upgrading or migrating to a new Files folder, the search indexes must be rebuilt. This can be done from Litium back office Settings > System Settings > Search Indeces.
In Litium 7 the Lucene search index can be used to search for content in the Sales, Websites and Products areas. In previous versions of Litium (5 and earlier) Lucene can be used to search for content in all areas.
Avaliable search indexes in Sales:
- ECommerceSearchDomains.Deliveries
- ECommerceSearchDomains.Orders
- ECommerceSearchDomains.Payments
Avaliable search indexes in Websites:
Avaliable search indexes in Products:
- ProductCatalogSearchDomains.Categories
- ProductCatalogSearchDomains.Products: The Products index only contains products that:
- have a valid field template
- have a valid display template
- have connected variants.
- ProductCatalogSearchDomains.ProductsAndCategories
It is possible to extract the search results in pages. Paging is important when you do not want to process the entire result set in a single go, and is mostly used when displaying the result in multiple pages to the end user.
This article shows how to obtain search results based on a "logical OR" operation of two search clauses. It looks more like two searches done in one go and the results combined.
It is possible to sort the search results in ascending or descending order.
A typical range search would be a price range search or a search for new products published between certain dates.
Tag terms are the values the search index has indexed.
The search filter can be built to exclude certain items by using an exclude tag clause.
If there are multiple hits for a given search string from different property fields, you can influence Lucene to prioritise a particular property field to search for over another, resulting in a prioritised search result. This is called boosting.
To specify how the search engine handles words/phrases you use analyzers.
Litium uses Elasticsearch as the search engine for searching on the Accelerator site. This article explains the general concepts and things to watch out for.
There are two levels to configureĀ the page index.