List of usage examples for org.apache.lucene.index IndexOptions NONE
IndexOptions NONE
To view the source code for org.apache.lucene.index IndexOptions NONE.
Click Source Link
From source file:com.basistech.lucene.tools.LuceneQueryToolTest.java
License:Apache License
@BeforeClass public static void oneTimeSetup() throws IOException, ParseException { LuceneQueryToolTest.showOutput = false; // for debugging tests Directory dir = new RAMDirectory(); Analyzer analyzer = new StandardAnalyzer(); IndexWriterConfig config = new IndexWriterConfig(analyzer); IndexWriter writer = new IndexWriter(dir, config); Document doc = new Document(); doc.add(new Field("longest-mention", "Bill Clinton", StringField.TYPE_STORED)); doc.add(new Field("context", "Hillary Clinton Arkansas", TextField.TYPE_NOT_STORED)); writer.addDocument(doc);/*from w ww . ja va2 s.com*/ doc = new Document(); doc.add(new Field("longest-mention", "George W. Bush", StringField.TYPE_STORED)); doc.add(new Field("context", "Texas Laura Bush", TextField.TYPE_NOT_STORED)); writer.addDocument(doc); doc = new Document(); doc.add(new Field("longest-mention", "George H. W. Bush", StringField.TYPE_STORED)); doc.add(new Field("context", "Barbara Bush Texas", TextField.TYPE_NOT_STORED)); writer.addDocument(doc); doc = new Document(); doc.add(new Field("bbb", "foo", StringField.TYPE_STORED)); doc.add(new Field("bbb", "bar", StringField.TYPE_STORED)); doc.add(new Field("aaa", "foo", StringField.TYPE_STORED)); FieldType typeUnindexed = new FieldType(StringField.TYPE_STORED); typeUnindexed.setIndexOptions(IndexOptions.NONE); doc.add(new Field("zzz", "foo", typeUnindexed)); writer.addDocument(doc); writer.close(); reader = DirectoryReader.open(dir); }
From source file:com.lngtop.es.plugin.index.mapper.TileFieldMapper.java
License:Apache License
private void parse(ParseContext context, GeoPoint point, String tile) throws IOException { if (point.lat() > 90.0 || point.lat() < -90.0) { throw new IllegalArgumentException("illegal latitude value [" + point.lat() + "] for " + name()); }// w w w . ja v a 2 s. c om if (point.lon() > 180.0 || point.lon() < -180) { throw new IllegalArgumentException("illegal longitude value [" + point.lon() + "] for " + name()); } if (fieldType().indexOptions() != IndexOptions.NONE || fieldType().stored()) { context.doc() .add(new GeoPointField(fieldType().names().indexName(), point.lon(), point.lat(), fieldType())); } if (tile == null) { tile = GeoUtils.latLongToGrid(point.lat(), point.lon()); } tileMapper.parse(context.createExternalValueContext(tile)); if (fieldType().isLatLonEnabled()) { latMapper.parse(context.createExternalValueContext(point.lat())); lonMapper.parse(context.createExternalValueContext(point.lon())); } multiFields.parse(this, context.createExternalValueContext(point)); }
From source file:com.ponysdk.sample.client.page.addon.SelectizeAddon.java
License:Apache License
public SelectizeAddon() { super(Element.newInput()); setTerminalHandler(this); ///*from w ww . java 2 s . co m*/ final Analyzer analyzer = new StandardAnalyzer(); final Directory directory = new RAMDirectory(); final IndexWriterConfig config = new IndexWriterConfig(analyzer); IndexWriter writer; try { writer = new IndexWriter(directory, config); final Document doc = new Document(); final String text = "Test de ouf"; final FieldType fieldType = new FieldType(); fieldType.setIndexOptions(IndexOptions.NONE); fieldType.setStored(true); fieldType.setTokenized(false); doc.add(new Field("id", "12", fieldType)); doc.add(new Field("fieldname", text, TextField.TYPE_STORED)); writer.addDocument(doc); addAssetsType(writer); addTenor(writer); addClients(writer); addSide(writer); writer.close(); } catch (final IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { // Now search the index: final DirectoryReader ireader = DirectoryReader.open(directory); isearcher = new IndexSearcher(ireader); // Parse a simple query that searches for "text": // final QueryParser parser = new QueryParser("fieldname", // analyzer); // parser.setFuzzyMinSim(2f); final Term term = new Term("fieldname", "indesfed"); final Query query = new FuzzyQuery(term); // final TopDocs hits = isearcher.search(query, 1000).scoreDocs; // final Query query = parser.parse("indeed"); final ScoreDoc[] hits = isearcher.search(query, 1000).scoreDocs; // Iterate through the results: for (final ScoreDoc hit : hits) { System.err.println("Score : " + hit.score); final Document hitDoc = isearcher.doc(hit.doc); System.err.println("Found document" + hitDoc.getField("fieldname").stringValue()); } // ireader.close(); // directory.close(); } catch (final Exception exception) { exception.printStackTrace(); } // <input type="text" id="input-tags3" class="demo-default" // value="science,biology,chemistry,physics"> }
From source file:com.ponysdk.sample.client.page.addon.SelectizeAddon.java
License:Apache License
private void addSide(final IndexWriter writer) throws IOException { final Document doc1 = new Document(); final FieldType fieldType1 = new FieldType(); fieldType1.setIndexOptions(IndexOptions.NONE); fieldType1.setStored(true);/*from w w w. jav a 2 s .co m*/ fieldType1.setTokenized(false); doc1.add(new Field("id", "sell", fieldType1)); doc1.add(new Field("fieldname", "Sell", TextField.TYPE_STORED)); doc1.add(new Field("fieldname", "S", TextField.TYPE_STORED)); doc1.add(new Field("type", Type.SIDE.name(), TextField.TYPE_STORED)); doc1.add(new Field("desc", "side", TextField.TYPE_STORED)); writer.addDocument(doc1); final Document doc2 = new Document(); final FieldType fieldType2 = new FieldType(); fieldType2.setIndexOptions(IndexOptions.NONE); fieldType2.setStored(true); fieldType2.setTokenized(false); doc2.add(new Field("id", "buy", fieldType2)); doc2.add(new Field("fieldname", "Buy", TextField.TYPE_STORED)); doc2.add(new Field("fieldname", "B", TextField.TYPE_STORED)); doc2.add(new Field("type", Type.SIDE.name(), TextField.TYPE_STORED)); doc2.add(new Field("desc", "side", TextField.TYPE_STORED)); writer.addDocument(doc2); }
From source file:com.ponysdk.sample.client.page.addon.SelectizeAddon.java
License:Apache License
private void addClients(final IndexWriter writer) throws IOException { final Document doc = new Document(); final FieldType fieldType1 = new FieldType(); fieldType1.setIndexOptions(IndexOptions.NONE); fieldType1.setStored(true);// w w w. jav a2 s . c o m fieldType1.setTokenized(false); doc.add(new Field("id", "pt", fieldType1)); doc.add(new Field("login", "p.task", TextField.TYPE_STORED)); doc.add(new Field("fieldname", "Peter Task", TextField.TYPE_STORED)); doc.add(new Field("desc", "client", TextField.TYPE_STORED)); doc.add(new Field("type", Type.CLIENT.name(), TextField.TYPE_STORED)); writer.addDocument(doc); }
From source file:com.ponysdk.sample.client.page.addon.SelectizeAddon.java
License:Apache License
private void addTenor(final IndexWriter writer) throws IOException { final String[] tenors = new String[] { "Y1", "Y2", "Y3", "Y4", "Y5", "Y6", "Y7", "Y8" }; for (final String tenor : tenors) { final Document doc = new Document(); final FieldType fieldType1 = new FieldType(); fieldType1.setIndexOptions(IndexOptions.NONE); fieldType1.setStored(true);//from ww w .j av a2 s. c o m fieldType1.setTokenized(false); doc.add(new Field("id", tenor, fieldType1)); final FieldType fieldType2 = new FieldType(); fieldType2.setIndexOptions(IndexOptions.DOCS); fieldType2.setStored(true); fieldType2.setTokenized(false); doc.add(new Field("fieldname", tenor, fieldType2)); doc.add(new Field("desc", "tenor", TextField.TYPE_STORED)); doc.add(new Field("type", Type.TENOR.name(), TextField.TYPE_STORED)); writer.addDocument(doc); } }
From source file:com.ponysdk.sample.client.page.addon.SelectizeAddon.java
License:Apache License
private void addAssetsType(final IndexWriter iwriter) throws IOException { final Document doc1 = new Document(); final FieldType fieldType1 = new FieldType(); fieldType1.setIndexOptions(IndexOptions.NONE); fieldType1.setStored(true);//from ww w. j ava2 s . c o m fieldType1.setTokenized(false); doc1.add(new Field("id", "-1", fieldType1)); doc1.add(new Field("fieldname", "Asset SWAP", TextField.TYPE_STORED)); doc1.add(new Field("fieldname", "SWAP", TextField.TYPE_STORED)); doc1.add(new Field("desc", "asset class", TextField.TYPE_STORED)); doc1.add(new Field("type", Type.CLASS.name(), TextField.TYPE_STORED)); iwriter.addDocument(doc1); final Document doc2 = new Document(); final FieldType fieldType2 = new FieldType(); fieldType2.setIndexOptions(IndexOptions.NONE); fieldType2.setStored(true); fieldType2.setTokenized(false); doc2.add(new Field("id", "-2", fieldType2)); doc2.add(new Field("fieldname", "Single IRS", TextField.TYPE_STORED)); doc2.add(new Field("fieldname", "IRS", TextField.TYPE_STORED)); doc2.add(new Field("desc", "asset class", TextField.TYPE_STORED)); doc2.add(new Field("type", Type.CLASS.name(), TextField.TYPE_STORED)); iwriter.addDocument(doc2); }
From source file:com.qwazr.search.field.CustomField.java
License:Apache License
protected CustomField(String name, FieldType type, Object value) { super(name, type); if (!type.stored() && type.indexOptions() == IndexOptions.NONE) throw new IllegalArgumentException( "it doesn't make sense to have a field that " + "is neither indexed nor stored"); if (value == null) throw new IllegalArgumentException("value cannot be null"); this.fieldsData = value; }
From source file:com.rocana.lucene.codec.v1.TestBlockPostingsFormat2.java
License:Apache License
private Document newDocument() { Document doc = new Document(); for (IndexOptions option : IndexOptions.values()) { if (option == IndexOptions.NONE) { continue; }/*from w w w . j a v a 2s .co m*/ FieldType ft = new FieldType(TextField.TYPE_NOT_STORED); // turn on tvs for a cross-check, since we rely upon checkindex in this test (for now) ft.setStoreTermVectors(true); ft.setStoreTermVectorOffsets(true); ft.setStoreTermVectorPositions(true); ft.setStoreTermVectorPayloads(true); ft.setIndexOptions(option); doc.add(new Field(option.toString(), "", ft)); } return doc; }
From source file:com.vmware.xenon.services.common.Lucene60FieldInfosFormatWithCache.java
License:Open Source License
private static IndexOptions getIndexOptions(IndexInput input, byte b) throws IOException { switch (b) {//w w w . ja va 2 s . c o m case 0: return IndexOptions.NONE; case 1: return IndexOptions.DOCS; case 2: return IndexOptions.DOCS_AND_FREQS; case 3: return IndexOptions.DOCS_AND_FREQS_AND_POSITIONS; case 4: return IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS; default: // BUG throw new CorruptIndexException("invalid IndexOptions byte: " + b, input); } }