gospodin
gospodin

Reputation: 1201

double value not indexed with Lucene 7

Helli,

I dont manage to index a double value with Lucene 7. After executing

public void indexDouble(Document document, String name, Double value) {
  double val = (double) value;
  document.add(new DoublePoint(name, val));
}

I am checking the indexed values with Luke and the value is always empty for this index.

After adding a DoublePoint to the document (in my case 44), when debugging I can see that the value is added

 DoublePoint <9xjcl4v4r:vq4ebgph8:44.0> stored<9xjcl4v4r:vq4ebgph8:44.0> 

stored but I dont see 'indexed' flag. Not sure if that is the problem since I am indexing in the same way long values and the search is working.

Any ideas?

Thank you

Upvotes: 1

Views: 357

Answers (1)

Mysterion
Mysterion

Reputation: 9320

To be fair with you, I highly doubt that it’s working as you describing.

The reason for this is following - all Point types, including DoublePoint are just indexed field and not stored, so they even have a remark in the JavaDoc saying:

An indexed double field for fast range filters. If you also need to store the value, you should add a separate StoredField instance.

The reason you see nothing in Luke is also pretty simple. Luke itself isn’t a magic and it could only show you values, if they are stored (which isn’t the case). However, you still could search for them, you just couldn’t retrieve them back.

For debugging/retrieving purpose you would need to add another stored field like this:

doc.add(new StoredField(“double_stored”, value));

Upvotes: 1

Related Questions