apache / apache/lucene

Query serialization using ObjectInput/OutputStream [LUCENE-5000]

Open
#6,064 3 comments 0 reactions 0 assignees View on GitHub
affects-version:4.3 legacy-jira-priority:Trivial module:core/search type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Reads and writes queries on ObjectInput/OutputStream.

No support for ConstantScoreQuery (no serialization for Filter) nor PayloadNearQuery and PayloadTermQuery (no serialization for PayloadFunction).

I might have missed to implement support for some core Queries. Currently supported are: TermQuery, BooleanQuery, WildcardQuery, PhraseQuery, MultiPhraseQuery, FuzzyQuery, RegexpQuery, TermRangeQuery, NumericRangeQuery, DisjunctionMaxQuery, MatchAllDocsQuery, SpanTermQuery, SpanMultiTermQueryWrapper, SpanNearQuery, SpanNotQuery, SpanOrQuery, FieldMaskingSpanQuery, SpanFirstQuery, SpanPositionRangeQuery, SpanPayloadCheckQuery and SpanNearPayloadCheckQuery.

Users are allowed to implement and register strategies for their own queries.

This will not allow you to serialize any object graph with aggregated Query instances e.g. Map<String, Query>, that would require a new implementation of ObjectOutputStream (one could base that on the GPL2 code from OpenJDK) or instrument the existing implementations to handle Query in private writeObjectA and similar methods.

There's a bit of reflection glue in this code in order to read private fields in query implementation. Not too happy about that, but not much to do unless one is to expose a bunch of new getters in all those classes.

The class is places in o.a.l.search in order to access package visible fields without getters. If moving to another package this would have to be handled using reflection as with above mentioned private fields.

---
Migrated from [LUCENE-5000](https://issues.apache.org/jira/browse/LUCENE-5000) by Karl Wettin, 1 vote, updated Feb 18 2014
Attachments: [LuceneQuerySerializer.java](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-5000/LuceneQuerySerializer.java), [TestLuceneQuerySerializer.java](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-5000/TestLuceneQuerySerializer.java)

Contributor guide

Open the contributing guide

Research direction

Start with the attached LuceneQuerySerializer.java and TestLuceneQuerySerializer.java, then review the listed supported queries and the missing ConstantScoreQuery, PayloadNearQuery, and PayloadTermQuery cases. Check how query strategies are registered and how reflection accesses query fields. Done means the requested query serialization support is implemented and covered by the serializer test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.