actually your intention is unclear ... are you wanting to run a single search 
and get back results from BOTH newsfeed and message? or do you want one or the 
other? if you want one or the other you could use my strategy which is to store 
the entity type as a field when indexing, e.g. 

<entity><field column="type" name="type_field" /></entity>
<entity><field column="type" name="type_field" /></entity>

note, if you don't have a foo column for type, make it up in your query, e.g. 
select n.*, 'Newsfeed' as type from ...

then for silo'd searches you would want to ensure a filter of type:Newsfeed. 
another handy thing is to facet.field=type and search (without a filter) as 
then you'll get back counts for your Newsfeed Message results too.


On Oct 14, 2010, at 5:44 AM, Allistair Crossley wrote:

> your first example is correct
> 
> <document>
> <entity name="newsfeed"></entity
> <entity name="message"></entity
> </document>
> 
> i have the same config for indexing 5 different tables
> 
> what you don't have from what i can see is a field name mapped to each 
> column, e.g.
> 
> <field column="nf_text" />
> 
> i always have to provide the destination field in schema.xml, e.g.
> 
> <field column="nf_text" name="the_field" />
> 
> 
> On Oct 14, 2010, at 5:22 AM, Anthony Maudry wrote:
> 
>> Hello,
>> 
>> I'm using Solr with a postgreSQL database. I need to search across two 
>> tables with no link between them.
>> 
>> ie : I have got a "messages" table and a "newsfeeds" table, nothing liking 
>> them.
>> 
>> I tried to configure my data-config.xml to implement this but it seems that 
>> tables can't be defined separately.
>> 
>> The configuration I first tried was the following :
>> 
>> <dataConfig>
>> <dataSource driver="org.postgresql.Driver" 
>> url="jdbc:postgresql://host/database" user="user" password="password" />
>> <document>
>> <entity name="newsfeeds" query="select id as nf_id, text as nf_text, url, 
>> note from newsfeeds" >
>> <field column="nf_text" />
>> </entity>
>> <entity name="messages" query="select id as m_id, body from messages" >
>> <field column="body" />
>> </entity>
>> </document>
>> </dataConfig>
>> 
>> Note that the two entities are at the same level. Only the first entity 
>> ("newsfeeds") will give results
>> 
>> I then tried this config :
>> 
>> <dataConfig>
>> <dataSource driver="org.postgresql.Driver" 
>> url="jdbc:postgresql://host/database" user="user" password="password" />
>> <document>
>> <entity name="newsfeeds" query="select id as nf_id, text as nf_text, url, 
>> note from newsfeeds" >
>> <field column="nf_text" />
>> <entity name="messages" query="select id as m_id, body from messages" >
>> <field column="body" />
>> </entity>
>> </entity>
>> </document>
>> </dataConfig>
>> 
>> As expected the results were crossed.
>> 
>> I wonder how I could implement the search over two independent tables?
>> 
>> Thanks for any answer.
>> 
>> Anthony
> 

Reply via email to