lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <erickerick...@gmail.com>
Subject Re: Fields with the same name
Date Wed, 15 Oct 2008 18:22:13 GMT
Yes, in terms of what you probably mean, but your first
example would index one token "bar1bar2". But if you
changed your first example to (note space): they would
be entirely equivalent.

   doc.add(new Field("foo",
                             "bar1 bar2",
                             Field.Store.YES,
                             Field.Index.ANALYZED));


One note: The rather technical difference between the two methods
is that multiple calls to index the same field add PositionIncrementGap
to the first token of calls 2-n. This defaults to 1, so it doesn't change
anything unless you change it in your analyzer. Don't worry about it
yet <G>...

Best
Erick



On Wed, Oct 15, 2008 at 1:41 PM, Rafael Almeida <almeidaraf@gmail.com>wrote:

> I didn't quite understand the Document documentation so well, the
> documentation says:
>
> "Adds a field to a document. Several fields may be added with the same
> name. In this case, if the fields are indexed, their text is treated
> as though appended for the purposes of search."
>
> Would
>
>    doc.add(new Field("foo",
>                              "bar1" + "bar2",
>                              Field.Store.YES,
>                              Field.Index.ANALYZED));
>
> be different in any way than
>
>    doc.add(new Field("foo",
>                              "bar1",
>                              Field.Store.YES,
>                              Field.Index.ANALYZED));
>    doc.add(new Field("foo",
>                              "bar2",
>                              Field.Store.YES,
>                              Field.Index.ANALYZED));
> ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message