Author: nfilotto
Date: 2010-12-30 07:52:09 -0500 (Thu, 30 Dec 2010)
New Revision: 3758
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChangesHolder.java
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
Log:
EXOJCR-1080: LazyTextExtractorField support added
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChangesHolder.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChangesHolder.java 2010-12-30
11:29:48 UTC (rev 3757)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChangesHolder.java 2010-12-30
12:52:09 UTC (rev 3758)
@@ -21,6 +21,7 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.Fieldable;
import java.io.Externalizable;
import java.io.IOException;
@@ -148,7 +149,7 @@
Field field;
if (value instanceof TokenStream)
{
- field = new Field(name, (TokenStream)value);
+ field = new Field(name, (TokenStream)value, getTermVectorParameter(flags));
}
else
{
@@ -255,7 +256,7 @@
out.writeBoolean(true);
// boost
out.writeFloat(doc.getBoost());
- List<Field> fields = doc.getFields();
+ List<Fieldable> fields = doc.getFields();
int l = fields.size();
out.writeInt(l);
for (int i = 0; i < l; i++)
@@ -274,7 +275,7 @@
* @param field the Field instance to serialize
* @throws IOException if the Field could not be serialized
*/
- private static void writeField(ObjectOutput out, Field field) throws IOException
+ private static void writeField(ObjectOutput out, Fieldable field) throws IOException
{
// Name
out.writeUTF(field.name());
@@ -295,7 +296,7 @@
* @param field the field from which we extract the value
* @throws IOException if the value could not be serialized
*/
- private static void writeValue(ObjectOutput out, Field field) throws IOException
+ private static void writeValue(ObjectOutput out, Fieldable field) throws IOException
{
Object o = field.stringValue();
if (o != null)
@@ -321,7 +322,7 @@
* @param field the field from which we extract the flags
* @throws IOException if the flags could not be serialized
*/
- private static void writeFlags(ObjectOutput out, Field field) throws IOException
+ private static void writeFlags(ObjectOutput out, Fieldable field) throws IOException
{
int flags = 0;
if (field.isStored())
Modified:
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
---
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-12-30
11:29:48 UTC (rev 3757)
+++
jcr/branches/1.14-IMPR/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-12-30
12:52:09 UTC (rev 3758)
@@ -878,48 +878,15 @@
* @param value the reader value.
* @return a lucene field.
*/
- protected Fieldable createFulltextField(Reader reader)
+ protected Fieldable createFulltextField(Reader value)
{
-
- StringBuffer textExtract = new StringBuffer();
- char[] buffer = new char[1024];
- int len;
- try
- {
- while ((len = reader.read(buffer)) > -1)
- {
- textExtract.append(buffer, 0, len);
- }
- }
- catch (IOException e)
- {
- log.warn("Exception reading value for field: " + e.getMessage());
- log.debug("Dump:", e);
- }
- finally
- {
- //IOUtils.closeQuietly(reader);
- try
- {
- reader.close();
- }
- catch (IOException e)
- {
- log.error(e.getLocalizedMessage(), e);
- }
- }
- String valueString = textExtract.toString();
-
if (supportHighlighting)
{
- //return new LazyTextExtractorField(FieldNames.FULLTEXT, value, true, true);
- return new Field(FieldNames.FULLTEXT, valueString, Field.Store.YES,
Field.Index.ANALYZED,
- Field.TermVector.WITH_OFFSETS);
+ return new LazyTextExtractorField(FieldNames.FULLTEXT, value, true, true);
}
else
{
- //return new LazyTextExtractorField(FieldNames.FULLTEXT, value, false, false);
- return new Field(FieldNames.FULLTEXT, valueString, Field.Store.NO,
Field.Index.ANALYZED, Field.TermVector.NO);
+ return new LazyTextExtractorField(FieldNames.FULLTEXT, value, false, false);
}
}