You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Andy <an...@yahoo.com> on 2010/10/01 13:38:49 UTC

Any way to "append" new text to an existing indexed field?

I'm building a Q&A application. There's a "Question" database table and an "Answer" table.

For each question, I'm putting the question itself plus all the answers into a single field "text" to be indexed and searched.

Say I have a question that has 10 existing answers that are already indexed. If a new answer is submitted for that question, is there any way I could just "append" the new answer to the "text" field? Or is the only way to implement this is to retrieve the original question and the 10 existing answers from the database, combine them with the newly submitted 11th answer, and re-index everything from scratch?

The latter option just seems inefficient. Is there a better design that could be used for this use case?

Andy


      

Re: Any way to "append" new text to an existing indexed field?

Posted by Allistair Crossley <al...@roxxor.co.uk>.
if your question + answers form a compound document then the whole document (with given unique id, e.g. question id) needs to be reindexed i think. best i could find with google was this ...

https://issues.apache.org/jira/browse/SOLR-139

On Oct 1, 2010, at 8:23 AM, Andy wrote:

> Well I want to just display the "title" of the question in my search results and users can then just click on it to see the detals of the question and all the answers.
> 
> For example, say a question has the title "What is the meaning of life?" and then one of the answers to that question is "solr." If someone searches for "solr", I want to display the question title "What is the meaning of life?" in the search results. If the user clicks on the question title and drills down, he can then see that one of the answers is "solr".
> 
> I'm not sure it makes sense to index the question and each answer separately because I don't want to get duplicate questions in the search results. In the above example, let's say there's another answer "solr is the meaning". If each answer is indexed separately, I'd get two "What is the meaning of life?" in my search results when someone searches for "solr".
> 
> --- On Fri, 10/1/10, Allistair Crossley <al...@roxxor.co.uk> wrote:
> 
>> From: Allistair Crossley <al...@roxxor.co.uk>
>> Subject: Re: Any way to "append" new text to an existing indexed field?
>> To: solr-user@lucene.apache.org
>> Date: Friday, October 1, 2010, 7:46 AM
>> i would say question and answer are 2
>> different entities. if you are using the data import
>> handler, i would personally create them as separate entities
>> with their own queries to the database using the deltaQuery
>> method to pick up only new rows. i guess it depends if you
>> need question + answers to actually come back out to be used
>> for display (i.e. you stored their data), or whether it's
>> good enough to match on question/answer separately and then
>> just link to a question ID in your UI to drill-down from the
>> database.
>> 
>> disclaimer: i am a solr novice - just started, so i'd see
>> what others think too ;)
>> 
>> On Oct 1, 2010, at 7:38 AM, Andy wrote:
>> 
>>> I'm building a Q&A application. There's a
>> "Question" database table and an "Answer" table.
>>> 
>>> For each question, I'm putting the question itself
>> plus all the answers into a single field "text" to be
>> indexed and searched.
>>> 
>>> Say I have a question that has 10 existing answers
>> that are already indexed. If a new answer is submitted for
>> that question, is there any way I could just "append" the
>> new answer to the "text" field? Or is the only way to
>> implement this is to retrieve the original question and the
>> 10 existing answers from the database, combine them with the
>> newly submitted 11th answer, and re-index everything from
>> scratch?
>>> 
>>> The latter option just seems inefficient. Is there a
>> better design that could be used for this use case?
>>> 
>>> Andy
>>> 
>>> 
>>> 
>> 
>> 
> 
> 
> 


Re: Any way to "append" new text to an existing indexed field?

Posted by Andy <an...@yahoo.com>.
Well I want to just display the "title" of the question in my search results and users can then just click on it to see the detals of the question and all the answers.

For example, say a question has the title "What is the meaning of life?" and then one of the answers to that question is "solr." If someone searches for "solr", I want to display the question title "What is the meaning of life?" in the search results. If the user clicks on the question title and drills down, he can then see that one of the answers is "solr".

I'm not sure it makes sense to index the question and each answer separately because I don't want to get duplicate questions in the search results. In the above example, let's say there's another answer "solr is the meaning". If each answer is indexed separately, I'd get two "What is the meaning of life?" in my search results when someone searches for "solr".

--- On Fri, 10/1/10, Allistair Crossley <al...@roxxor.co.uk> wrote:

> From: Allistair Crossley <al...@roxxor.co.uk>
> Subject: Re: Any way to "append" new text to an existing indexed field?
> To: solr-user@lucene.apache.org
> Date: Friday, October 1, 2010, 7:46 AM
> i would say question and answer are 2
> different entities. if you are using the data import
> handler, i would personally create them as separate entities
> with their own queries to the database using the deltaQuery
> method to pick up only new rows. i guess it depends if you
> need question + answers to actually come back out to be used
> for display (i.e. you stored their data), or whether it's
> good enough to match on question/answer separately and then
> just link to a question ID in your UI to drill-down from the
> database.
> 
> disclaimer: i am a solr novice - just started, so i'd see
> what others think too ;)
> 
> On Oct 1, 2010, at 7:38 AM, Andy wrote:
> 
> > I'm building a Q&A application. There's a
> "Question" database table and an "Answer" table.
> > 
> > For each question, I'm putting the question itself
> plus all the answers into a single field "text" to be
> indexed and searched.
> > 
> > Say I have a question that has 10 existing answers
> that are already indexed. If a new answer is submitted for
> that question, is there any way I could just "append" the
> new answer to the "text" field? Or is the only way to
> implement this is to retrieve the original question and the
> 10 existing answers from the database, combine them with the
> newly submitted 11th answer, and re-index everything from
> scratch?
> > 
> > The latter option just seems inefficient. Is there a
> better design that could be used for this use case?
> > 
> > Andy
> > 
> > 
> > 
> 
> 


      

Re: Any way to "append" new text to an existing indexed field?

Posted by Allistair Crossley <al...@roxxor.co.uk>.
i would say question and answer are 2 different entities. if you are using the data import handler, i would personally create them as separate entities with their own queries to the database using the deltaQuery method to pick up only new rows. i guess it depends if you need question + answers to actually come back out to be used for display (i.e. you stored their data), or whether it's good enough to match on question/answer separately and then just link to a question ID in your UI to drill-down from the database.

disclaimer: i am a solr novice - just started, so i'd see what others think too ;)

On Oct 1, 2010, at 7:38 AM, Andy wrote:

> I'm building a Q&A application. There's a "Question" database table and an "Answer" table.
> 
> For each question, I'm putting the question itself plus all the answers into a single field "text" to be indexed and searched.
> 
> Say I have a question that has 10 existing answers that are already indexed. If a new answer is submitted for that question, is there any way I could just "append" the new answer to the "text" field? Or is the only way to implement this is to retrieve the original question and the 10 existing answers from the database, combine them with the newly submitted 11th answer, and re-index everything from scratch?
> 
> The latter option just seems inefficient. Is there a better design that could be used for this use case?
> 
> Andy
> 
> 
>