Java Code Examples for org.apache.lucene.document.FieldType#storeTermVectorPositions()
The following examples show how to use
org.apache.lucene.document.FieldType#storeTermVectorPositions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldMapper.java From Elasticsearch with Apache License 2.0 | 6 votes |
public static String termVectorOptionsToString(FieldType fieldType) { if (!fieldType.storeTermVectors()) { return "no"; } else if (!fieldType.storeTermVectorOffsets() && !fieldType.storeTermVectorPositions()) { return "yes"; } else if (fieldType.storeTermVectorOffsets() && !fieldType.storeTermVectorPositions()) { return "with_offsets"; } else { StringBuilder builder = new StringBuilder("with"); if (fieldType.storeTermVectorPositions()) { builder.append("_positions"); } if (fieldType.storeTermVectorOffsets()) { builder.append("_offsets"); } if (fieldType.storeTermVectorPayloads()) { builder.append("_payloads"); } return builder.toString(); } }
Example 2
Source File: FieldMapper.java From crate with Apache License 2.0 | 6 votes |
public static String termVectorOptionsToString(FieldType fieldType) { if (!fieldType.storeTermVectors()) { return "no"; } else if (!fieldType.storeTermVectorOffsets() && !fieldType.storeTermVectorPositions()) { return "yes"; } else if (fieldType.storeTermVectorOffsets() && !fieldType.storeTermVectorPositions()) { return "with_offsets"; } else { StringBuilder builder = new StringBuilder("with"); if (fieldType.storeTermVectorPositions()) { builder.append("_positions"); } if (fieldType.storeTermVectorOffsets()) { builder.append("_offsets"); } if (fieldType.storeTermVectorPayloads()) { builder.append("_payloads"); } return builder.toString(); } }
Example 3
Source File: LuceneTestCase.java From lucene-solr with Apache License 2.0 | 4 votes |
public synchronized static Field newField(Random random, String name, Object value, FieldType type) { // Defeat any consumers that illegally rely on intern'd // strings (we removed this from Lucene a while back): name = new String(name); FieldType prevType = fieldToType.get(name); if (usually(random) || type.indexOptions() == IndexOptions.NONE || prevType != null) { // most of the time, don't modify the params if (prevType == null) { fieldToType.put(name, new FieldType(type)); } else { type = mergeTermVectorOptions(type, prevType); } return createField(name, value, type); } // TODO: once all core & test codecs can index // offsets, sometimes randomly turn on offsets if we are // already indexing positions... FieldType newType = new FieldType(type); if (!newType.stored() && random.nextBoolean()) { newType.setStored(true); // randomly store it } // Randomly turn on term vector options, but always do // so consistently for the same field name: if (!newType.storeTermVectors() && random.nextBoolean()) { newType.setStoreTermVectors(true); if (!newType.storeTermVectorPositions()) { newType.setStoreTermVectorPositions(random.nextBoolean()); if (newType.storeTermVectorPositions()) { if (!newType.storeTermVectorPayloads()) { newType.setStoreTermVectorPayloads(random.nextBoolean()); } } } if (!newType.storeTermVectorOffsets()) { newType.setStoreTermVectorOffsets(random.nextBoolean()); } if (VERBOSE) { System.out.println("NOTE: LuceneTestCase: upgrade name=" + name + " type=" + newType); } } newType.freeze(); fieldToType.put(name, newType); // TODO: we need to do this, but smarter, ie, most of // the time we set the same value for a given field but // sometimes (rarely) we change it up: /* if (newType.omitNorms()) { newType.setOmitNorms(random.nextBoolean()); } */ return createField(name, value, newType); }