Skip to content

Erro ao criar índice com valor nulo #2524

Answered by alcaeus
JefersonCelestino asked this question in Q&A
Discussion options

You must be logged in to vote

The sparse index option doesn't exclude documents where a single field in a compound index is null. From the documentation:

Only indexes documents that contain a value for at least one of the keys.

In this case, you should be using partial indexes. These offer a superset of the sparse index functionality by letting you define your own criteria for including a document in the index. However, the partialFilterExpression only supports a subset of the usual filter criteria. In this case, you'd be looking to exclude any document where numRps or serieRps is not null. Usually, this would result in this filter (note that the example does not work):

$options = [
    'unique' => true,
    'partia…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by divine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants