Search code examples
solrdataimporthandler

Solr SEARCH BY entity name


<dataConfig>
        <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver">        
        <document>
                <entity name="MALE_PROFILES"
                query="SELECT ID , COLUMN1 , COLUMN2,male FROM MALE_PROFILES "
                 transformer="RegexTransformer">
                        <field name="id" column="ID">
                </entity>
                <entity name="FEMALE_PROFILES"
                query="SELECT ID , COLUMN1 , COLUMN2,female FROM FEMALE_PROFILES"
                 transformer="RegexTransformer">
                        <field name="id" column="ID">
                </entity>
        </document>
</dataConfig>

Currently my search is based on male and female, which should be slow. Can I search based on entity name like MALE_PROFILE ?


Solution

  • Its not going to be slow unless you have lots and lots of records with a huge index size.
    For search based on entities, you can add a identifier to the male and female profiles and use filter queries to limit the searched entities which will use the filter cache as well. e.g.

    if you add a fixed column with your male and female entities,

    SELECT ID , COLUMN1 , COLUMN2,male, 'MALE' AS PROFILE FROM MALE_PROFILES

    you can apply the filter using fq=profile:MALE