You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by 齐保元 <qi...@126.com> on 2012/07/20 07:59:49 UTC

how to deal with multi subject problem?

Hi buddy,
             I have many documents and each document may belong to *MANY* subjects.How to use Lucene to deal with this situation to meet the demand of seaching under specific subject?



Re: how to deal with multi subject problem?

Posted by Ian Lea <ia...@gmail.com>.
Just add the different subjects to the document e.g.

Doc doc = new Document();
for (String subject : subjects) {
  Field f = new Field("subject", subject, ...);
  doc.add(f);
}

Or concatenate the subjects and store the one long string.

If you don't want a search to potentially match terms from multiple
subjects look into phrase queries or spans or position increments.

If you haven't yet read Lucene In Action 2nd edition it would be well
worth doing so.


--
Ian.

On Fri, Jul 20, 2012 at 6:59 AM, 齐保元 <qi...@126.com> wrote:
> Hi buddy,
>              I have many documents and each document may belong to *MANY* subjects.How to use Lucene to deal with this situation to meet the demand of seaching under specific subject?
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org