List of usage examples for org.apache.lucene.index FieldInfo hasNorms
public boolean hasNorms()
From source file:com.github.flaxsearch.api.FieldData.java
License:Apache License
public FieldData(FieldInfo fieldInfo) { this.name = fieldInfo.name; this.indexOptions = fieldInfo.getIndexOptions(); this.hasNorms = fieldInfo.hasNorms(); this.docValuesType = fieldInfo.getDocValuesType(); this.pointDimensionCount = fieldInfo.getPointDimensionCount(); this.hasPayloads = fieldInfo.hasPayloads(); }
From source file:com.vmware.xenon.services.common.FieldInfoCache.java
License:Open Source License
public static boolean equals(FieldInfo a, FieldInfo b) { return a.number == b.number && a.name.equals(b.name) && a.getPointDimensionCount() == b.getPointDimensionCount() && a.getPointNumBytes() == b.getPointNumBytes() && a.getDocValuesGen() == b.getDocValuesGen() && a.getIndexOptions() == b.getIndexOptions() && a.hasPayloads() == b.hasPayloads() && a.hasVectors() == b.hasVectors() && a.omitsNorms() == b.omitsNorms() && a.hasNorms() == b.hasNorms(); }
From source file:org.eu.bitzone.Leia.java
License:Apache License
private void addFieldRow(final Object table, final String fName, final IndexableField ixf, final int docid, final TFIDFSimilarity sim) { final Object row = create("row"); add(table, row);/*from w w w . j a v a2 s . com*/ putProperty(row, "field", ixf); putProperty(row, "fName", fName); Object cell = create("cell"); setString(cell, "text", fName); add(row, cell); cell = create("cell"); final Field f = (Field) ixf; String flags = Util.fieldFlags(f, infos.fieldInfo(fName)); boolean hasVectors = false; try { hasVectors = ar.getTermVector(docid, fName) != null; } catch (final Exception e) { // ignore } // consider skipping this field altogether? if (ixf == null && !hasVectors) { setBoolean(cell, "enabled", false); } if (hasVectors) { flags = flags.substring(0, 7) + "V" + flags.substring(8); } setString(cell, "text", flags); setFont(cell, "font", courier); setChoice(cell, "alignment", "center"); add(row, cell); cell = create("cell"); final FieldInfo info = infos.fieldInfo(fName); if (f != null) { try { if (ar != null && info.hasNorms()) { ar.getFieldInfos().fieldInfo(fName).getNormType(); final NumericDocValues norms = ar.getNormValues(fName); final String val = Util.normsToString(norms, fName, docid, sim); setString(cell, "text", val); } else { setString(cell, "text", "---"); setBoolean(cell, "enabled", false); } } catch (final IOException ioe) { ioe.printStackTrace(); setString(cell, "text", "!?!"); } } else { setString(cell, "text", "---"); setBoolean(cell, "enabled", false); } add(row, cell); cell = create("cell"); if (f != null) { String text = f.stringValue(); if (text == null) { if (f.binaryValue() != null) { text = Util.bytesToHex(f.binaryValue(), false); } else { text = "(null)"; } } Decoder dec = decoders.get(f.name()); if (dec == null) { dec = defDecoder; } try { if (f.fieldType().stored()/* && f.numericValue() == null && f.binaryValue() == null */) { text = dec.decodeStored(f.name(), f); } else { text = dec.decodeTerm(f.name(), text); } } catch (final Throwable e) { setColor(cell, "foreground", Color.RED); } setString(cell, "text", Util.escape(text)); } else { setString(cell, "text", "<not present or not stored>"); setBoolean(cell, "enabled", false); } add(row, cell); }
From source file:org.eu.bitzone.Leia.java
License:Apache License
public void actionExamineNorm(final Object table) throws Exception { final Object row = getSelectedItem(table); if (row == null) { return;/*from www . java2 s . c om*/ } if (ir == null) { showStatus(MSG_NOINDEX); return; } final Field f = (Field) getProperty(row, "field"); if (f == null) { showStatus("No data available for this field"); return; } final FieldInfo info = infos.fieldInfo(f.name()); if (!info.isIndexed()) { showStatus("Cannot examine norm value - this field is not indexed."); return; } if (!info.hasNorms()) { showStatus("Cannot examine norm value - this field has no norms."); return; } final Object dialog = addComponent(null, "/xml/fnorm.xml", null, null); final Integer docNum = (Integer) getProperty(table, "docNum"); putProperty(dialog, "docNum", getProperty(table, "docNum")); putProperty(dialog, "field", f); final Object curNorm = find(dialog, "curNorm"); final Object newNorm = find(dialog, "newNorm"); final Object encNorm = find(dialog, "encNorm"); final Object doc = find(dialog, "docNum"); final Object fld = find(dialog, "fld"); final Object srchOpts = find("srchOptTabs"); final Similarity sim = createSimilarity(srchOpts); TFIDFSimilarity s = null; if (sim != null && sim instanceof TFIDFSimilarity) { s = (TFIDFSimilarity) sim; } else { s = defaultSimilarity; } setString(doc, "text", String.valueOf(docNum.intValue())); setString(fld, "text", f.name()); putProperty(dialog, "similarity", s); if (ar != null) { try { final NumericDocValues norms = ar.getNormValues(f.name()); byte curBVal = 0; if (norms != null) { curBVal = (byte) norms.get(docNum.intValue()); } final float curFVal = Util.decodeNormValue(curBVal, f.name(), s); setString(curNorm, "text", String.valueOf(curFVal)); setString(newNorm, "text", String.valueOf(curFVal)); setString(encNorm, "text", String.valueOf(curFVal) + " (0x" + Util.byteToHex(curBVal) + ")"); } catch (final Exception e) { e.printStackTrace(); errorMsg("Error reading norm: " + e.toString()); return; } } add(dialog); displayNewNorm(dialog); }
From source file:org.getopt.luke.Luke.java
License:Apache License
private void addFieldRow(Object table, String fName, IndexableField ixf, int docid, TFIDFSimilarity sim) { Object row = create("row"); add(table, row);//from w w w .j a v a 2 s. com putProperty(row, "field", ixf); putProperty(row, "fName", fName); Object cell = create("cell"); setString(cell, "text", fName); add(row, cell); cell = create("cell"); Field f = (Field) ixf; String flags = Util.fieldFlags(f, infos.fieldInfo(fName)); boolean hasVectors = false; try { hasVectors = ar.getTermVector(docid, fName) != null; } catch (Exception e) { // ignore } // consider skipping this field altogether? if (ixf == null && !hasVectors) { setBoolean(cell, "enabled", false); } if (hasVectors) { flags = flags.substring(0, 7) + "V" + flags.substring(8); } setString(cell, "text", flags); setFont(cell, "font", courier); setChoice(cell, "alignment", "center"); add(row, cell); cell = create("cell"); FieldInfo info = infos.fieldInfo(fName); if (f != null) { try { if (ar != null && info.hasNorms()) { NumericDocValues norms = ar.getNormValues(fName); String val = Long.toString(norms.get(docid)); setString(cell, "text", val); } else { setString(cell, "text", "---"); setBoolean(cell, "enabled", false); } } catch (IOException ioe) { ioe.printStackTrace(); setString(cell, "text", "!?!"); } } else { setString(cell, "text", "---"); setBoolean(cell, "enabled", false); } add(row, cell); cell = create("cell"); if (f != null) { String text = f.stringValue(); if (text == null) { if (f.binaryValue() != null) { text = Util.bytesToHex(f.binaryValue(), false); } else { text = "(null)"; } } Decoder dec = decoders.get(f.name()); if (dec == null) dec = defDecoder; try { if (f.fieldType().stored()/* && f.numericValue() == null && f.binaryValue() == null*/) { text = dec.decodeStored(f.name(), f); } else { text = dec.decodeTerm(f.name(), text); } } catch (Throwable e) { setColor(cell, "foreground", Color.RED); } setString(cell, "text", Util.escape(text)); } else { setString(cell, "text", "<not present or not stored>"); setBoolean(cell, "enabled", false); } add(row, cell); }
From source file:org.getopt.luke.Luke.java
License:Apache License
public void actionExamineNorm(Object table) throws Exception { Object row = getSelectedItem(table); if (row == null) return;/* ww w . j a v a 2s .c om*/ if (ir == null) { showStatus(MSG_NOINDEX); return; } Field f = (Field) getProperty(row, "field"); if (f == null) { showStatus("No data available for this field"); return; } FieldInfo info = infos.fieldInfo(f.name()); if (!info.isIndexed()) { showStatus("Cannot examine norm value - this field is not indexed."); return; } if (!info.hasNorms()) { showStatus("Cannot examine norm value - this field has no norms."); return; } Object dialog = addComponent(null, "/xml/fnorm.xml", null, null); Integer docNum = (Integer) getProperty(table, "docNum"); putProperty(dialog, "docNum", getProperty(table, "docNum")); putProperty(dialog, "field", f); Object curNorm = find(dialog, "curNorm"); Object newNorm = find(dialog, "newNorm"); Object encNorm = find(dialog, "encNorm"); Object doc = find(dialog, "docNum"); Object fld = find(dialog, "fld"); Object srchOpts = find("srchOptTabs"); Similarity sim = createSimilarity(srchOpts); TFIDFSimilarity s = null; if (sim != null && (sim instanceof TFIDFSimilarity)) { s = (TFIDFSimilarity) sim; } else { s = defaultSimilarity; } setString(doc, "text", String.valueOf(docNum.intValue())); setString(fld, "text", f.name()); putProperty(dialog, "similarity", s); if (ar != null) { try { NumericDocValues norms = ar.getNormValues(f.name()); byte curBVal = (byte) norms.get(docNum.intValue()); float curFVal = Util.decodeNormValue(curBVal, f.name(), s); setString(curNorm, "text", String.valueOf(curFVal)); setString(newNorm, "text", String.valueOf(curFVal)); setString(encNorm, "text", String.valueOf(curFVal) + " (0x" + Util.byteToHex(curBVal) + ")"); } catch (Exception e) { e.printStackTrace(); errorMsg("Error reading norm: " + e.toString()); return; } } add(dialog); displayNewNorm(dialog); }
From source file:perf.DiskUsage.java
License:Apache License
static String features(FieldInfo fi) { StringBuilder sb = new StringBuilder(); IndexOptions options = fi.getIndexOptions(); if (options != IndexOptions.NONE) { String words[] = options.toString().split("_"); sb.append(words[words.length - 1].toLowerCase()); sb.append(" "); }/*from w w w. j a v a 2 s . com*/ if (fi.hasPayloads()) { sb.append("payloads "); } if (fi.hasNorms()) { sb.append("norms "); } if (fi.hasVectors()) { sb.append("vectors "); } if (fi.getPointDimensionCount() != 0) { sb.append(fi.getPointNumBytes()); sb.append("bytes/"); sb.append(fi.getPointDimensionCount()); sb.append("D "); } DocValuesType dvType = fi.getDocValuesType(); if (dvType != DocValuesType.NONE) { sb.append(dvType.toString().toLowerCase()); } return sb.toString().trim(); }