Java Code Examples for org.apache.lucene.document.Field#Index
The following examples show how to use
org.apache.lucene.document.Field#Index .
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: HardwareDeviceDocumentBuilder.java From uyuni with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || (name.equals("description"))) { store = Field.Store.YES; } else if (name.equals("serverId")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 2
Source File: XccdfIdentDocumentBuilder.java From uyuni with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 3
Source File: HardwareDeviceDocumentBuilder.java From spacewalk with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || (name.equals("description"))) { store = Field.Store.YES; } else if (name.equals("serverId")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 4
Source File: XccdfIdentDocumentBuilder.java From spacewalk with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 5
Source File: ErrataDocumentBuilder.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.NO; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || name.equals("advisoryName")) { store = Field.Store.YES; } else if (name.equals("synopsis") || name.equals("description") || name.equals("topic") || name.equals("solution")) { // index, but do not store } else { // skip - do not store or index continue; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 6
Source File: ServerDocumentBuilder.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); // Keep 'id' UN_TOKENIZED, this is needed to determine 'uniqueness' // if you tokenize this it will break deleting documents, we'll // no longer have unique documents per id. doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); // This is the tokenized form of 'id' so we can do searches on it and // use ngram flexibility doc.add(new Field("system_id", objId.toString(), Field.Store.YES, Field.Index.TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || name.equals("cpuModel") || name.equals("hostname") || name.equals("ipaddr") || name.equals("ip6addr") || (name.equals("runningKernel"))) { store = Field.Store.YES; } else if (name.equals("checkin") || name.equals("registered") || name.equals("ram") || name.equals("swap") || name.equals("cpuMHz") | name.equals("cpuNumberOfCpus")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 7
Source File: ServerCustomInfoDocumentBuilder.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("value")) { store = Field.Store.YES; } else if (name.equals("created") || (name.equals("modified"))) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } else if (name.equals("serverId") || name.equals("createdBy") || name.equals("lastModifiedBy")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 8
Source File: PackageDocumentBuilder.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter .hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name")) { store = Field.Store.YES; } else if (name.equals("arch") || name.equals("filename") || name.equals("version") || name.equals("release") || name.equals("epoch")) { tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 9
Source File: SnapshotTagDocumentBuilder.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name")) { store = Field.Store.YES; } else if (name.equals("created") || (name.equals("modified"))) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } else if (name.equals("snapshotId") || name.equals("tagNameId") || name.equals("serverId") || name.equals("orgId")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 10
Source File: ErrataDocumentBuilder.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.NO; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || name.equals("advisoryName")) { store = Field.Store.YES; } else if (name.equals("synopsis") || name.equals("description") || name.equals("topic") || name.equals("solution")) { // index, but do not store } else { // skip - do not store or index continue; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 11
Source File: ServerDocumentBuilder.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); // Keep 'id' UN_TOKENIZED, this is needed to determine 'uniqueness' // if you tokenize this it will break deleting documents, we'll // no longer have unique documents per id. doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); // This is the tokenized form of 'id' so we can do searches on it and // use ngram flexibility doc.add(new Field("system_id", objId.toString(), Field.Store.YES, Field.Index.TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name") || name.equals("cpuModel") || name.equals("hostname") || name.equals("ipaddr") || name.equals("ip6addr") || (name.equals("runningKernel"))) { store = Field.Store.YES; } else if (name.equals("checkin") || name.equals("registered") || name.equals("ram") || name.equals("swap") || name.equals("cpuMHz") | name.equals("cpuNumberOfCpus")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 12
Source File: ServerCustomInfoDocumentBuilder.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("value")) { store = Field.Store.YES; } else if (name.equals("created") || (name.equals("modified"))) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } else if (name.equals("serverId") || name.equals("createdBy") || name.equals("lastModifiedBy")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 13
Source File: PackageDocumentBuilder.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter .hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name")) { store = Field.Store.YES; } else if (name.equals("arch") || name.equals("filename") || name.equals("version") || name.equals("release") || name.equals("epoch")) { tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 14
Source File: SnapshotTagDocumentBuilder.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ public Document buildDocument(Long objId, Map<String, String> metadata) { Document doc = new Document(); doc.add(new Field("id", objId.toString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); for (Iterator<String> iter = metadata.keySet().iterator(); iter.hasNext();) { Field.Store store = Field.Store.YES; Field.Index tokenize = Field.Index.TOKENIZED; String name = iter.next(); String value = metadata.get(name); if (name.equals("name")) { store = Field.Store.YES; } else if (name.equals("created") || (name.equals("modified"))) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } else if (name.equals("snapshotId") || name.equals("tagNameId") || name.equals("serverId") || name.equals("orgId")) { store = Field.Store.YES; tokenize = Field.Index.UN_TOKENIZED; } doc.add(new Field(name, String.valueOf(value), store, tokenize)); } return doc; }
Example 15
Source File: OlatDocument.java From olat with Apache License 2.0 | 4 votes |
private Field createField(String fieldName, String content, Field.Index fieldIndex, float wight) { Field field = new Field(fieldName, content, Field.Store.YES, fieldIndex); field.setBoost(wight); return field; }
Example 16
Source File: OlatDocument.java From olat with Apache License 2.0 | 4 votes |
private Field createField(String fieldName, String content, Field.Index fieldIndex, float wight) { Field field = new Field(fieldName, content, Field.Store.YES, fieldIndex); field.setBoost(wight); return field; }