Java Code Examples for org.apache.lucene.document.FloatPoint#newSetQuery()
The following examples show how to use
org.apache.lucene.document.FloatPoint#newSetQuery() .
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: TestPointQueries.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testPointInSetEquals() { Query q1, q2; q1 = IntPoint.newSetQuery("a", 0, 1000, 17); q2 = IntPoint.newSetQuery("a", 17, 0, 1000); assertEquals(q1, q2); assertEquals(q1.hashCode(), q2.hashCode()); assertFalse(q1.equals(IntPoint.newSetQuery("a", 1, 17, 1000))); assertFalse(q1.equals(IntPoint.newSetQuery("b", 0, 1000, 17))); q1 = LongPoint.newSetQuery("a", 0, 1000, 17); q2 = LongPoint.newSetQuery("a", 17, 0, 1000); assertEquals(q1, q2); assertEquals(q1.hashCode(), q2.hashCode()); assertFalse(q1.equals(LongPoint.newSetQuery("a", 1, 17, 1000))); q1 = FloatPoint.newSetQuery("a", 0, 1000, 17); q2 = FloatPoint.newSetQuery("a", 17, 0, 1000); assertEquals(q1, q2); assertEquals(q1.hashCode(), q2.hashCode()); assertFalse(q1.equals(FloatPoint.newSetQuery("a", 1, 17, 1000))); q1 = DoublePoint.newSetQuery("a", 0, 1000, 17); q2 = DoublePoint.newSetQuery("a", 17, 0, 1000); assertEquals(q1, q2); assertEquals(q1.hashCode(), q2.hashCode()); assertFalse(q1.equals(DoublePoint.newSetQuery("a", 1, 17, 1000))); byte[] zeros = new byte[5]; byte[] ones = new byte[5]; Arrays.fill(ones, (byte) 0xff); q1 = BinaryPoint.newSetQuery("a", new byte[][] {zeros, ones}); q2 = BinaryPoint.newSetQuery("a", new byte[][] {zeros, ones}); assertEquals(q1, q2); assertEquals(q1.hashCode(), q2.hashCode()); byte[] other = ones.clone(); other[2] = (byte) 5; assertFalse(q1.equals(BinaryPoint.newSetQuery("a", new byte[][] {zeros, other}))); }
Example 2
Source File: NumberFieldMapper.java From crate with Apache License 2.0 | 5 votes |
@Override public Query termsQuery(String field, List<Object> values) { float[] v = new float[values.size()]; for (int i = 0; i < values.size(); ++i) { v[i] = parse(values.get(i), false); } return FloatPoint.newSetQuery(field, v); }
Example 3
Source File: TestMemoryIndexAgainstDirectory.java From lucene-solr with Apache License 2.0 | 4 votes |
public void testPointValuesMemoryIndexVsNormalIndex() throws Exception { int size = atLeast(12); List<Integer> randomValues = new ArrayList<>(); Document doc = new Document(); for (Integer randomInteger : random().ints(size).toArray()) { doc.add(new IntPoint("int", randomInteger)); randomValues.add(randomInteger); doc.add(new LongPoint("long", randomInteger)); doc.add(new FloatPoint("float", randomInteger)); doc.add(new DoublePoint("double", randomInteger)); } MockAnalyzer mockAnalyzer = new MockAnalyzer(random()); MemoryIndex memoryIndex = MemoryIndex.fromDocument(doc, mockAnalyzer); IndexSearcher memoryIndexSearcher = memoryIndex.createSearcher(); Directory dir = newDirectory(); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), mockAnalyzer)); writer.addDocument(doc); writer.close(); IndexReader controlIndexReader = DirectoryReader.open(dir); IndexSearcher controlIndexSearcher = new IndexSearcher(controlIndexReader); Supplier<Integer> valueSupplier = () -> randomValues.get(random().nextInt(randomValues.size())); Query[] queries = new Query[] { IntPoint.newExactQuery("int", valueSupplier.get()), LongPoint.newExactQuery("long", valueSupplier.get()), FloatPoint.newExactQuery("float", valueSupplier.get()), DoublePoint.newExactQuery("double", valueSupplier.get()), IntPoint.newSetQuery("int", valueSupplier.get(), valueSupplier.get()), LongPoint.newSetQuery("long", valueSupplier.get(), valueSupplier.get()), FloatPoint.newSetQuery("float", valueSupplier.get(), valueSupplier.get()), DoublePoint.newSetQuery("double", valueSupplier.get(), valueSupplier.get()), IntPoint.newRangeQuery("int", valueSupplier.get(), valueSupplier.get()), LongPoint.newRangeQuery("long", valueSupplier.get(), valueSupplier.get()), FloatPoint.newRangeQuery("float", valueSupplier.get(), valueSupplier.get()), DoublePoint.newRangeQuery("double", valueSupplier.get(), valueSupplier.get()) }; for (Query query : queries) { assertEquals(controlIndexSearcher.count(query), controlIndexSearcher.count(query)); } memoryIndexSearcher.getIndexReader().close(); controlIndexReader.close(); dir.close(); }