How to know which returned data belong to which entity in solr/solrj?

StackOverflow https://stackoverflow.com/questions/21923659

  •  14-10-2022
  •  | 
  •  

Вопрос

I have defined many entities in solr. For example,

<document name="content">
    <entity name="post" query="SELECT * FROM post">
            // field mappings
        </entity>
        <entity name="category" query="select * from category " >
           // field mappings    
        </entity>
</document>

I'm using solrj to perform searching tasks. When searching a keyword, for instance 'facebook', both post and category containing the keyword 'facebook' so solr returns data of post and category. But how can I know which data belong to post and which ones belong to category entity? (I use solr 4.x)

Это было полезно?

Решение

Better keep a common field (say "entity") in both type of Solr doc. Store the entity name for each one. When you query, by the entity value, you'll know the result belongs to which entity.

E.g For entity "post" keep entity:post

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top