Search code examples
elasticsearchmanticore-search

How to perform a wildcard query in Manticore Search?


I am tired of Elasticsearch's appetite and am searching for an alternative. Then, I found Manticore: https://manticoresearch.com/

Everything seems fine, but wildcard queries. In ES I use a lot of wildcard queries, like '*word', '*word*' and 'word*'. Manticore does support MySQL protocol, but does not support LIKE queries, so I couldn't find any way to perform this type of queries. Any thoughts?


Solution

  • In Manticore Search you can perform wildcard queries using the MATCH() with the IN and ANYoperators.

    Here is an approach of how you can achieve:

    Like how you use %in for example MSSQL, you can use * operator to perform LIKE operations.

    If the value contains word:

    SELECT * FROM <index> WHERE MATCH('@<field> *word*');
    

    If the value ends with word

    SELECT * FROM <index> WHERE MATCH('@<field> *word');
    

    If the value starts with word

    SELECT * FROM <index> WHERE MATCH('@<field> word*');
    

    With IN operation

    SELECT * FROM <table> WHERE <column> IN ('Airplane', 'Vehicle');
    

    With ANY operation

    SELECT * FROM <table> WHERE ANY(<column>) IN ('value1', 'value2', 'value3');