Commit Graph

37425 Commits

Author SHA1 Message Date
Armin Braun c41eb227ea
Introduce singleton for PackedInts.NullReader of size 256 (#13232)
Size 256 is very common here throguh the monotonic long values default
page size. In ES we're seing many MB O(10M) of duplicate instances of this
size relatively quickly.
=> adding a singleton for it to save some heap
2024-03-29 13:54:04 +01:00
Adrien Grand 32d692049f
Replace (IO)Context#READ with (IO)Context.DEFAULT. (#13242)
`DEFAULT` doesn't mean much today and could be used whenever `READ` is used. So
let's use `DEFAULT` all the time instead and remove `READ`.
2024-03-29 10:37:26 +01:00
Adrien Grand 4a3f4cfe97
Make `OneMerge#reorder` preserve blocks. (#13128)
This updates `IndexWriter` to only call `OneMerge#reorder` when it has a chance
to preserve the block structure, ie. either there are no blocks or blocks are
identified by a parent field.

Furthermore, `MockRandomMergePolicy` is updated to preserve the block structure
when a parent field is configured.
2024-03-29 10:07:22 +01:00
Adrien Grand a807772d41
More consistently use a SEQUENTIAL ReadAdvice for merging. (#13229)
Merging `IOContext`s use a `SEQUENTIAL` `ReadAdvice`. However, some file
formats hardcode `IOContext.LOAD` for some of their files, which silences the
whole merging context, in particular the `SEQUENTIAL` `ReadAdvice`.

This PR switches file formats to
`ioContext.withReadAdvice(ReadAdvice.RANDOM_PRELOAD)` so that merges will use a
`SEQUENTIAL` `ReadAdvice` while searches will use a `RANDOM_PRELOAD`
`ReadAdvice`.

This is not a huge deal for `RANDOM_PRELOAD`, which is only used for very small
files. However, this change becomes more relevant for the new `RANDOM`
`ReadAdvice` as we would like merges to keep using a `SEQUENTIAL` `ReadAdvice`.
2024-03-29 09:14:14 +01:00
Kaival Parikh 878d233bc1
Mark TimeLimitingCollector as deprecated (#13220)
Co-authored-by: Kaival Parikh <kaivalp2000@gmail.com>
2024-03-29 09:12:48 +01:00
Tommaso Teofili 42a5ff6ace
Test KNN query works seamlessly regardless of underlying format (#13225)
* Test Knn query on different vector formats
2024-03-29 08:28:33 +01:00
Armin Braun 6cba773318
Use singleton for all-zeros DirectMonotonicReader.Meta (#13224)
Having a single block of all zeros is a fairly common case that is using
a lot of heap for duplicate instances in some use-cases in ES.
=> read a singleton for it to save the duplication
2024-03-29 07:23:00 +01:00
Robert Muir 8f4e449669
Add RomanianNormalizationFilter (#13233) 2024-03-28 18:35:39 -04:00
Robert Muir a7e916223c
remove unnecessary chmod+x, file is marked executable in snowball git 2024-03-28 16:43:47 -04:00
Robert Muir 3553769463
remove now-unnecessary snowball mojibake hack (#13231) 2024-03-28 16:40:55 -04:00
Robert Muir 11712a3364
remove unsupported snowball algorithms (#13230) 2024-03-28 16:37:18 -04:00
Trey Jones 69d846f700
Add Romanian stopwords with s&t with comma (#12172)
Romanian uses s&t with commas (ș/ț), but for a long time those weren't available, so s&t with cedilla (ş/ţ) were used. Both are still in use, but the comma forms are much more common now. Both should be supported in stopword lists.
2024-03-28 10:35:39 -04:00
Uwe Schindler f6d0834639 fix typo in older changes entry 2024-03-28 10:39:34 +01:00
Uwe Schindler 376ec27a51 #13206: Move changes entry to 9.11 2024-03-28 10:37:45 +01:00
Jean-François BOEUF 3917d22591
Subtract deleted file size from the cache size of NRTCachingDirectory. (#13206) 2024-03-28 10:34:46 +01:00
Robert Muir ad8545151d
upgrade snowball to 34f3612e5e8c (round two) (#13227)
* upgrade snowball to 34f3612e5e8c (round two)

* disable forbidden-apis on snowball code (thanks @uschindler)
2024-03-27 17:51:48 -04:00
Adrien Grand 96c0c3082a
Clean up variable-gaps terms format. (#13216)
The variable-gaps terms format uses the legacy storage layout of storing
metadata at the end of the index file, and storing the start pointer of the
metadata as the last 8 bytes of the index files (just before the footer). This
forces an awkward access pattern at open time when we first need to seek
towards the end to check that a footer is present, then seek some more bytes
backwards to read metadata, and finally read the content of the index that sits
before metadata.

To fix this, meta data and index data are now split into different files. This
way, both files have a clean sequential and read-once access pattern, and can
take advantage of the `ChecksumIndexInput` abstraction for checksum validation.

This further helps clean up `IOContext` by removing the ability to set
`readOnce` to `true` on an existing `IOContext`.
2024-03-27 18:16:30 +01:00
Robert Muir d54663ad76
upgrade snowball to 26db1ab9adbf437f37a6facd3ee2aad1da9eba03 (#13209)
* upgrade snowball to 26db1ab9adbf437f37a6facd3ee2aad1da9eba03

* add back-compat-hack to the factory, too

* remove open of irish package now that we don't have our own stopwords file here anymore

* CHANGES / MIGRATE
2024-03-27 10:05:57 -04:00
Adrien Grand 8558934501
Replace boolean flags on `IOContext` with an enum. (#13219)
This replaces the `load`, `randomAccess` and `readOnce` flags with a
`ReadAdvice` enum, whose values are aligned with the allowed values to
(f|m)advise.

Closes #13211
2024-03-27 09:13:41 +01:00
Zhang Chao 1f909baca5
Speed up writeGroupVInts (#13203)
* Speed up writeGroupVInts
2024-03-26 22:48:30 +08:00
Uwe Schindler 26f5065e15
Add support for Github issue numbers in Markdown converter (e.g., MIGRATE.md file) (#13215) 2024-03-26 13:45:56 +01:00
gf2121 99b9636fd8
Break point estimation when threshold exceeded (#13199) 2024-03-26 19:29:34 +08:00
Uwe Schindler 8c4ec1dbef
Convert IOContext, MergeInfo, and FlushInfo to record classes (#13205) 2024-03-26 12:27:51 +01:00
Chris Hegarty 209aa05c0c
Avoid creating large buffer in TestMMapDirectory.testWithRandom (#13214)
This commit avoids creating an unnecessary large buffer in TestMMapDirectory.testWithRandom.
2024-03-26 10:35:17 +00:00
Uwe Schindler 9fffc6e54c #13196, #13213: Remove logging relic from main branch 2024-03-26 10:09:29 +01:00
Uwe Schindler 61e5da3fe4 #13196, #13213: Fix test on windows to close file so it can be deleted after test run 2024-03-25 20:37:59 +01:00
Uwe Schindler a4055dae62
Add support for posix_madvise to Java 21 MMapDirectory (#13196) 2024-03-25 18:44:33 +01:00
Nhat Nguyen f4db67fae2
Avoid modify merge state in per field mergers (#13208)
The PerFieldDocValuesFormat and PerFieldPostingsFormat mutate and reset 
the fieldInfos of the mergeState during merges. Consequently, other 
running merge sub-tasks may fail to see some fieldInfos. This was
problematic since we introduced concurrency for merge sub-tasks.

Relates #13190
2024-03-25 08:56:41 -07:00
Tim Grein d5ef6edf7f
Only check the knn specific options, if a vector dictionary source was provided. (#13163) 2024-03-25 10:25:50 -04:00
Uwe Schindler 04f335ad79 Upgrade forbiddenapis to version 3.7 and ASM for APIJAR extraction to 9.7 2024-03-24 00:09:24 +01:00
Uwe Schindler 00073c4c1a
Fix equals/hashcode of IOContext (#13204) 2024-03-23 12:03:27 +01:00
Benjamin Trent 75e1ebc450
Add new parallel merge task executor for parallel actions within a single merge action (#13190)
This commit adds a new interface to all MergeScheduler classes that allows the scheduler to provide an Executor for intra-merge parallelism. The first sub-class to satisfy this new interface is the ConcurrentMergeScheduler (CMS). In particular, the CMS will limit the amount of parallelism based on the current number of mergeThreads and the configured maxThread options. 

Parallelism is now added by default to the SegmentMerger where each merging task is executed in parallel with the others. 

Additionally, the Lucene99 HNSW codec will use the provided MergeScheduler executor if no executor is provided directly.

Relates to: https://github.com/apache/lucene/issues/12740
Relates to: https://github.com/apache/lucene/issues/9626

This is a take 2 of: https://github.com/apache/lucene/pull/13124
2024-03-21 09:11:00 -04:00
Benjamin Trent d5f8853fda
Fix NPE for when fields are missing in `searchNearestVectors` (#13195)
Related to: https://github.com/apache/lucene/pull/13162

Since this is unreleased, no changelog entry is necessary.
2024-03-20 11:49:30 -04:00
Shintaro Murakami c78533c53c
Support getMaxScore of DisjunctionSumScorer for non top level scoring clause (#13066) 2024-03-20 10:37:48 +01:00
panguixin 7a08eeab47
Make the HitQueue size more appropriate for KNN exact search (#13184)
Currently, when performing KNN exact search, we consistently set the HitQueue size to k. However, there may be instances where the number of candidates is actually lower than k.
2024-03-19 12:24:36 -04:00
Dai Sugimori d393b9d039
Add new token filters for Japanese sutegana (捨て仮名) (#12915)
### Description

Sutegana (捨て仮名) is small letter of hiragana and katakana in Japanese. In the old Japanese text, sutegana (捨て仮名) is not used unlikely to modern one. For example:

- "ストップウォッチ" is written as "ストツプウオツチ"
- "ちょっとまって" is written as "ちよつとまつて"

So it's meaningful to normalize sutegana to normal (uppercase) characters if we search against the corpus which includes old Japanese text such as patents, legal documents, contract policies, etc.

This pull request introduces 2 token filters:

- JapaneseHiraganaUppercaseFilter for hiragana
- JapaneseKatakanaUppercaseFilter for katakana

so that user can use either one separately. Each. filter make all the sutegana (small characters) into normal kana (uppercase character) to normalize the token.

### Why it is needed

This transformation must be done as token filter. There have already been [MappingCharFilter](https://lucene.apache.org/core/8_0_0/analyzers-common/org/apache/lucene/analysis/charfilter/MappingCharFilter.html), but if we apply this character filter to normalize sutegana, it will impact to tokenization and it is not expected.
2024-03-18 08:50:36 -04:00
Benjamin Trent 5b48474286
Revert "Add new parallel merge task executor for parallel actions within a si…" (#13189)
This reverts commit e3a34bfe56.
2024-03-18 08:31:42 -04:00
Zhang Chao 9fd0474251
Remove the unnecessary grow before append. (#13168) 2024-03-16 17:33:18 +08:00
Zhang Chao 6ee19c022c
Introduce IORunnable to fix test failure TestIndexWriterOnDiskFull.testAddIndexOnDiskFull (#13172) 2024-03-16 08:38:53 +08:00
Benjamin Trent e3a34bfe56
Add new parallel merge task executor for parallel actions within a single merge action (#13124)
This commit adds a new interface to all MergeScheduler classes that allows the scheduler to provide an Executor for intra-merge parallelism. The first sub-class to satisfy this new interface is the ConcurrentMergeScheduler (CMS). In particular, the CMS will limit the amount of parallelism based on the current number of mergeThreads and the configured maxThread options. 

Parallelism is now added by default to the SegmentMerger where each merging task is executed in parallel with the others. 

Additionally, the Lucene99 HNSW codec will use the provided MergeScheduler executor if no executor is provided directly.

Relates to: https://github.com/apache/lucene/issues/12740
Relates to: https://github.com/apache/lucene/issues/9626
2024-03-14 15:58:41 -04:00
Adrien Grand 3ad73336ae
Make BP work on indexes that have blocks. (#13125)
The current logic for reordering splits a slice of doc IDs into a left side and
a right side, and for each document it computes the expected gain of moving to
the other side. Then it swaps documents from both sides as long as the sum of
the gain of moving the left doc to the right and the right doc to the left is
positive.

This works well, but I would like to extend BP reordering to also work with
blocks, and the swapping logic is challenging to modify as two parent documents
may have different numbers of children.

One of the follow-up papers on BP suggested to use a different logic, where one
would compute a bias for all documents that is negative when a document is
attracted to the left and positive otherwise. Then we only have to partition doc
IDs around the mid point, e.g. with quickselect.

A benefit of this change is that it will make it easier to generalize BP
reordering to indexes that have blocks, e.g. by using a stable sort on biases.
2024-03-13 10:14:14 +01:00
Dawid Weiss d5ade0d30f
Remove halt() call in TestSimpleServer (part of TestStressNRTReplication (#13177) 2024-03-13 09:03:34 +01:00
Benjamin Trent b527e101e7
Fix potential race condition in DocumentsWriter & DocumentsWriterDeleteQueue (#13169)
* Fix potential race condition in DocumentsWriter & DocumentsWriterDeleteQueue

* add changes
2024-03-12 07:50:04 -04:00
Tim Grein 44fa35b65f
Adjust middle of sentence calculation and add test verifying correct behavior (#13170) 2024-03-11 13:21:22 +01:00
Tim Grein 3f4413567d
Fix TestFloatVectorSimilarityQuery.testBoostQuery (#13176)
### Description

The boosted doc scores were the same due to floating point precision limitations, when multiplying the original scores with tiny differences with a fairly large multiplier.

My change removes the assertion expecting the exact order to be the same (AFAIU this won't be possible for every scores/boost configurations due to precision limitations), but rather asserts that the `original doc score * boost factor` and the `boosted doc score` are equals within a certain delta.

Closes https://github.com/apache/lucene/issues/13173.
2024-03-11 08:08:29 -04:00
panguixin 5b5815a26d
Fix NPE when LeafReader return null VectorValues (#13162)
### Description
`LeafReader#getXXXVectorValues` may return null value.

**Reproduction**:
```
public class TestKnnByteVectorQuery extends BaseKnnVectorQueryTestCase {
  public void testVectorEncodingMismatch() throws IOException {
    try (Directory indexStore =
        getIndexStore("field", new float[] {0, 1}, new float[] {1, 2}, new float[] {0, 0});
        IndexReader reader = DirectoryReader.open(indexStore)) {
      AbstractKnnVectorQuery query =
          new KnnFloatVectorQuery("field", new float[] {0, 1}, 10);
      IndexSearcher searcher = newSearcher(reader);
      searcher.search(query, 10);
    }
  }
}
```
**Output**:
```
java.lang.NullPointerException: Cannot invoke "org.apache.lucene.index.FloatVectorValues.size()" because the return value of "org.apache.lucene.index.LeafReader.getFloatVectorValues(String)" is null
```
2024-03-11 08:07:04 -04:00
zhouhui 6445bc0a14
Rename TestWildcard to TestWildcardQuery. (#13159) 2024-03-08 09:26:44 -05:00
Dawid Weiss 1c77e2315c
An eye-gouging way to limit suppressAccessChecks to just the three JARs that need them. (#13164) 2024-03-08 08:10:49 +01:00
Tim Grein 49db29e59f
Check whether document exists without relying on the id (#13160) 2024-03-06 05:50:59 -05:00
Benjamin Trent 012b959b05
Add mult-leaf optimizations for diversify children collector (#13121)
This adds multi-leaf optimizations for diversified children collector. This means as children vectors are collected within a block join, we can share information between leaves to speed up vector search.

To make this happen, I refactored the multi-leaf collector slightly. Now, instead of inheriting from TopKnnCollector, we inject a inner collector.
2024-03-05 09:02:49 -05:00