apache / apache/lucene

SpanNearQuery inconsistency: should it accept less than 2 clauses or not? [LUCENE-2577]

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

Description

NearSpansOrdered's constructor will throw an IllegalArgumentException
if less than 2 clauses are given, while NearSpansOrdered won't.

On the other hand, SpanNearQuery accepts less than 2 clauses and has explicit optimization for 0-caluse and 1-clause queries in getSpans() method.

So, should SpanNearQuery accept less than 2 clauses or not?

---
Migrated from [LUCENE-2577](https://issues.apache.org/jira/browse/LUCENE-2577) by Santiago M. Mola

Contributor guide

Open the contributing guide

Research direction

Start by comparing NearSpansOrdered's constructor behavior with SpanNearQuery's handling of fewer than two clauses in getSpans(). Review the existing zero-clause and one-clause optimizations and determine the intended consistent contract. Done means the accepted clause counts and resulting behavior are explicitly decided and consistently reflected.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.