@Test public void testCreateFieldNoTF() throws Exception{ fieldDescription.setMerge(true); fieldDescription.setIndex(FieldBuilder.FIELD_INDEX_NO_TF); TokenStream tokenStream = createMock(TokenStream.class); expect(filterBuilder.filter(isA(TokenStreamMerger.class), isA(Collection.class))).andReturn(tokenStream); replay(filterBuilder); Collection<Field> fields = fieldBuilder.createFields(tokenStreams, fieldDescription); verify(filterBuilder); Iterator<Field> fieldIterator = fields.iterator(); Field field1 = fieldIterator.next(); assertEquals("field1", field1.name()); assertTrue(field1.getOmitTf()); assertFalse(field1.getOmitNorms()); assertTrue(field1.isIndexed()); assertFalse(field1.isStored()); }
public Collection<Field> createFields(Collection<TokenStream> tokenStreams, FieldDescription fieldDescription) throws FieldBuildingException { TokenStream tokenStream = createFieldTokenStream(tokenStreams, fieldDescription); this.fieldDescription = fieldDescription; String fieldName = fieldDescription.getName(); String delimiter = fieldDescription.getDelimiter(); Collection<Field> fields = new ArrayList<Field>(); Collection<FilterDescription> filterDescriptions = fieldDescription .getFilterDescriptions(); tokenStream = getFilteredTokenStream(fieldName, tokenStream, filterDescriptions); Boolean unique = fieldDescription.getUnique(); Boolean coverField = fieldDescription.getTermCoverDescription() != null; Field.Store fieldStore = getFieldStore(fieldDescription.getStored()); Field.Index fieldIndex = getFieldIndex(fieldDescription.getIndex()); Field.TermVector fieldTermVector = getFieldTermVector(fieldDescription .getTermVector()); boolean omitTF = fieldDescription.getIndex().equals(FIELD_INDEX_NO_TF) || fieldDescription.getIndex().equals(FIELD_INDEX_NO_NORMS_TF); boolean store = fieldStore == Field.Store.YES || fieldStore == Field.Store.COMPRESS; if (!coverField) { if (store) fields.addAll(createStoredFields(fieldName, tokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(fieldName, tokenStream, fieldIndex, fieldTermVector, omitTF)); } else { TermCoverBuilder termCoverBuilder = termCoverBuilderFactory .createTermCoverBuilder(tokenStream, fieldDescription.getTermCoverDescription()); while (termCoverBuilder.increaseCoverSubset()) { String coverSubsetName = termCoverBuilder.getCoverSubsetName(); TokenStream coverSubsetTokenStream = termCoverBuilder .getPartitionTokenStream(); if (store) fields.addAll(createStoredFields(coverSubsetName, coverSubsetTokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(coverSubsetName, coverSubsetTokenStream, fieldIndex, fieldTermVector, omitTF)); } } return fields; }
FieldBuilder { public Collection<Field> createFields(Collection<TokenStream> tokenStreams, FieldDescription fieldDescription) throws FieldBuildingException { TokenStream tokenStream = createFieldTokenStream(tokenStreams, fieldDescription); this.fieldDescription = fieldDescription; String fieldName = fieldDescription.getName(); String delimiter = fieldDescription.getDelimiter(); Collection<Field> fields = new ArrayList<Field>(); Collection<FilterDescription> filterDescriptions = fieldDescription .getFilterDescriptions(); tokenStream = getFilteredTokenStream(fieldName, tokenStream, filterDescriptions); Boolean unique = fieldDescription.getUnique(); Boolean coverField = fieldDescription.getTermCoverDescription() != null; Field.Store fieldStore = getFieldStore(fieldDescription.getStored()); Field.Index fieldIndex = getFieldIndex(fieldDescription.getIndex()); Field.TermVector fieldTermVector = getFieldTermVector(fieldDescription .getTermVector()); boolean omitTF = fieldDescription.getIndex().equals(FIELD_INDEX_NO_TF) || fieldDescription.getIndex().equals(FIELD_INDEX_NO_NORMS_TF); boolean store = fieldStore == Field.Store.YES || fieldStore == Field.Store.COMPRESS; if (!coverField) { if (store) fields.addAll(createStoredFields(fieldName, tokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(fieldName, tokenStream, fieldIndex, fieldTermVector, omitTF)); } else { TermCoverBuilder termCoverBuilder = termCoverBuilderFactory .createTermCoverBuilder(tokenStream, fieldDescription.getTermCoverDescription()); while (termCoverBuilder.increaseCoverSubset()) { String coverSubsetName = termCoverBuilder.getCoverSubsetName(); TokenStream coverSubsetTokenStream = termCoverBuilder .getPartitionTokenStream(); if (store) fields.addAll(createStoredFields(coverSubsetName, coverSubsetTokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(coverSubsetName, coverSubsetTokenStream, fieldIndex, fieldTermVector, omitTF)); } } return fields; } }
FieldBuilder { public Collection<Field> createFields(Collection<TokenStream> tokenStreams, FieldDescription fieldDescription) throws FieldBuildingException { TokenStream tokenStream = createFieldTokenStream(tokenStreams, fieldDescription); this.fieldDescription = fieldDescription; String fieldName = fieldDescription.getName(); String delimiter = fieldDescription.getDelimiter(); Collection<Field> fields = new ArrayList<Field>(); Collection<FilterDescription> filterDescriptions = fieldDescription .getFilterDescriptions(); tokenStream = getFilteredTokenStream(fieldName, tokenStream, filterDescriptions); Boolean unique = fieldDescription.getUnique(); Boolean coverField = fieldDescription.getTermCoverDescription() != null; Field.Store fieldStore = getFieldStore(fieldDescription.getStored()); Field.Index fieldIndex = getFieldIndex(fieldDescription.getIndex()); Field.TermVector fieldTermVector = getFieldTermVector(fieldDescription .getTermVector()); boolean omitTF = fieldDescription.getIndex().equals(FIELD_INDEX_NO_TF) || fieldDescription.getIndex().equals(FIELD_INDEX_NO_NORMS_TF); boolean store = fieldStore == Field.Store.YES || fieldStore == Field.Store.COMPRESS; if (!coverField) { if (store) fields.addAll(createStoredFields(fieldName, tokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(fieldName, tokenStream, fieldIndex, fieldTermVector, omitTF)); } else { TermCoverBuilder termCoverBuilder = termCoverBuilderFactory .createTermCoverBuilder(tokenStream, fieldDescription.getTermCoverDescription()); while (termCoverBuilder.increaseCoverSubset()) { String coverSubsetName = termCoverBuilder.getCoverSubsetName(); TokenStream coverSubsetTokenStream = termCoverBuilder .getPartitionTokenStream(); if (store) fields.addAll(createStoredFields(coverSubsetName, coverSubsetTokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(coverSubsetName, coverSubsetTokenStream, fieldIndex, fieldTermVector, omitTF)); } } return fields; } FieldBuilder(FilterBuilder filterBuilder); }
FieldBuilder { public Collection<Field> createFields(Collection<TokenStream> tokenStreams, FieldDescription fieldDescription) throws FieldBuildingException { TokenStream tokenStream = createFieldTokenStream(tokenStreams, fieldDescription); this.fieldDescription = fieldDescription; String fieldName = fieldDescription.getName(); String delimiter = fieldDescription.getDelimiter(); Collection<Field> fields = new ArrayList<Field>(); Collection<FilterDescription> filterDescriptions = fieldDescription .getFilterDescriptions(); tokenStream = getFilteredTokenStream(fieldName, tokenStream, filterDescriptions); Boolean unique = fieldDescription.getUnique(); Boolean coverField = fieldDescription.getTermCoverDescription() != null; Field.Store fieldStore = getFieldStore(fieldDescription.getStored()); Field.Index fieldIndex = getFieldIndex(fieldDescription.getIndex()); Field.TermVector fieldTermVector = getFieldTermVector(fieldDescription .getTermVector()); boolean omitTF = fieldDescription.getIndex().equals(FIELD_INDEX_NO_TF) || fieldDescription.getIndex().equals(FIELD_INDEX_NO_NORMS_TF); boolean store = fieldStore == Field.Store.YES || fieldStore == Field.Store.COMPRESS; if (!coverField) { if (store) fields.addAll(createStoredFields(fieldName, tokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(fieldName, tokenStream, fieldIndex, fieldTermVector, omitTF)); } else { TermCoverBuilder termCoverBuilder = termCoverBuilderFactory .createTermCoverBuilder(tokenStream, fieldDescription.getTermCoverDescription()); while (termCoverBuilder.increaseCoverSubset()) { String coverSubsetName = termCoverBuilder.getCoverSubsetName(); TokenStream coverSubsetTokenStream = termCoverBuilder .getPartitionTokenStream(); if (store) fields.addAll(createStoredFields(coverSubsetName, coverSubsetTokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(coverSubsetName, coverSubsetTokenStream, fieldIndex, fieldTermVector, omitTF)); } } return fields; } FieldBuilder(FilterBuilder filterBuilder); Collection<Field> createFields(Collection<TokenStream> tokenStreams,
			FieldDescription fieldDescription); }
FieldBuilder { public Collection<Field> createFields(Collection<TokenStream> tokenStreams, FieldDescription fieldDescription) throws FieldBuildingException { TokenStream tokenStream = createFieldTokenStream(tokenStreams, fieldDescription); this.fieldDescription = fieldDescription; String fieldName = fieldDescription.getName(); String delimiter = fieldDescription.getDelimiter(); Collection<Field> fields = new ArrayList<Field>(); Collection<FilterDescription> filterDescriptions = fieldDescription .getFilterDescriptions(); tokenStream = getFilteredTokenStream(fieldName, tokenStream, filterDescriptions); Boolean unique = fieldDescription.getUnique(); Boolean coverField = fieldDescription.getTermCoverDescription() != null; Field.Store fieldStore = getFieldStore(fieldDescription.getStored()); Field.Index fieldIndex = getFieldIndex(fieldDescription.getIndex()); Field.TermVector fieldTermVector = getFieldTermVector(fieldDescription .getTermVector()); boolean omitTF = fieldDescription.getIndex().equals(FIELD_INDEX_NO_TF) || fieldDescription.getIndex().equals(FIELD_INDEX_NO_NORMS_TF); boolean store = fieldStore == Field.Store.YES || fieldStore == Field.Store.COMPRESS; if (!coverField) { if (store) fields.addAll(createStoredFields(fieldName, tokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(fieldName, tokenStream, fieldIndex, fieldTermVector, omitTF)); } else { TermCoverBuilder termCoverBuilder = termCoverBuilderFactory .createTermCoverBuilder(tokenStream, fieldDescription.getTermCoverDescription()); while (termCoverBuilder.increaseCoverSubset()) { String coverSubsetName = termCoverBuilder.getCoverSubsetName(); TokenStream coverSubsetTokenStream = termCoverBuilder .getPartitionTokenStream(); if (store) fields.addAll(createStoredFields(coverSubsetName, coverSubsetTokenStream, fieldStore, delimiter, unique, fieldIndex, omitTF)); if (fieldIndex != Field.Index.NO && (!unique || !store)) fields.add(createIndexedField(coverSubsetName, coverSubsetTokenStream, fieldIndex, fieldTermVector, omitTF)); } } return fields; } FieldBuilder(FilterBuilder filterBuilder); Collection<Field> createFields(Collection<TokenStream> tokenStreams,
			FieldDescription fieldDescription); static final String FIELD_INDEX_NO; static final String FIELD_INDEX_YES; static final String FIELD_INDEX_NO_NORMS; static final String FIELD_INDEX_NO_TF; static final String FIELD_INDEX_NO_NORMS_TF; static final String FIELD_TERM_VECTOR_NO; static final String FIELD_TERM_VECTOR_YES; static final String FIELD_TERM_VECTOR_WITH_OFFSETS; static final String FIELD_TERM_VECTOR_WITH_POSITIONS; static final String FIELD_TERM_VECTOR_WITH_POSITIONS_OFFSETS; static final String FIELD_STORE_NO; static final String FIELD_STORE_YES; static final String FIELD_STORE_COMPRESS; }