meilisearch/milli/src/update
bors[bot] 21284cf235
Merge #556
556: Add EXISTS filter r=loiclec a=loiclec

## What does this PR do?

Fixes issue [#2484](https://github.com/meilisearch/meilisearch/issues/2484) in the meilisearch repo.

It creates a `field EXISTS` filter which selects all documents containing the `field` key. 
For example, with the following documents:
```json
[{
	"id": 0,
	"colour": []
},
{
	"id": 1,
	"colour": ["blue", "green"]
},
{
	"id": 2,
	"colour": 145238
},
{
	"id": 3,
	"colour": null
},
{
	"id": 4,
	"colour": {
		"green": []
	}
},
{
	"id": 5,
	"colour": {}
},
{
	"id": 6
}]
```
Then the filter `colour EXISTS` selects the ids `[0, 1, 2, 3, 4, 5]`. The filter `colour NOT EXISTS` selects `[6]`.

## Details
There is a new database named `facet-id-exists-docids`. Its keys are field ids and its values are bitmaps of all the document ids where the corresponding field exists.

To create this database, the indexing part of milli had to be adapted. The implementation there is basically copy/pasted from the code handling the `facet-id-f64-docids` database, with appropriate modifications in place.

There was an issue involving the flattening of documents during (re)indexing. Previously, the following JSON:
```json
{
    "id": 0,
    "colour": [],
    "size": {}
}
```
would be flattened to:
```json
{
    "id": 0
}
```
prior to being given to the extraction pipeline.

This transformation would lose the information that is needed to populate the `facet-id-exists-docids` database. Therefore, I have also changed the implementation of the `flatten-serde-json` crate. Now, as it traverses the Json, it keeps track of which key was encountered. Then, at the end, if a previously encountered key is not present in the flattened object, it adds that key to the object with an empty array as value. For example:
```json
{
    "id": 0,
    "colour": {
        "green": [],
        "blue": 1
    },
    "size": {}
} 
```
becomes
```json
{
    "id": 0,
    "colour": [],
    "colour.green": [],
    "colour.blue": 1,
    "size": []
} 
```


Co-authored-by: Kerollmops <clement@meilisearch.com>
2022-08-04 09:46:06 +00:00
..
index_documents Merge #556 2022-08-04 09:46:06 +00:00
available_documents_ids.rs Fasten the document deletion 2022-07-05 15:30:33 +02:00
clear_documents.rs Merge branch 'filter/field-exist' 2022-07-21 14:51:41 +02:00
delete_documents.rs Merge branch 'filter/field-exist' 2022-07-21 14:51:41 +02:00
facets.rs Merge #436 2022-02-16 15:41:14 +00:00
indexer_config.rs document batch support 2022-01-19 12:40:20 +01:00
mod.rs Expose the DocumentId struct to be sure to inject the generated ids 2022-07-12 15:14:06 +02:00
settings.rs Fix the indexation tests 2022-07-12 14:55:51 +02:00
update_step.rs Implement documents format 2021-09-21 16:58:33 +02:00
word_prefix_docids.rs Make sure that we do not generate too long keys 2022-05-03 10:03:15 +02:00
word_prefix_pair_proximity_docids.rs Make sure that we do not generate too long keys 2022-05-03 10:03:15 +02:00
words_prefix_position_docids.rs Make sure that we do not generate too long keys 2022-05-03 10:03:15 +02:00
words_prefixes_fst.rs review edits 2022-03-15 17:12:48 +01:00