Skip to content

Add the SearchParamType parameter to the Map method of IElementIndexer. #1385

Description

@whyfate

Fields of type string within a SearchParameter definition may be classified as either string or token. Unless these types are handled separately, queries must account for the differing storage mechanisms of both types, necessitating or queries and thereby impacting performance.

var plainStringQueries = new List<FilterDefinition<BsonDocument>>{
Builders<BsonDocument>.Filter.Type(parameterName, BsonType.String)};

return modifier == Modifier.NOT ?
Builders<BsonDocument>.Filter.And(Builders<BsonDocument>.Filter.Not(arrayEqQuery),
Builders<BsonDocument>.Filter.Not(noArrayEqQuery), Builders<BsonDocument>.Filter.Not(plainStringQuery))
: Builders<BsonDocument>.Filter.Or(arrayEqQuery, noArrayEqQuery, plainStringQuery);

If the Map method accepts a SearchParamType parameter, the type can be evaluated during the ToExpressions phase:

if (searchParamType == SearchParamType.Token)
{
    var values = new List<IndexValue>
    {
        new IndexValue("code", new StringValue(element.Value)),
    };

    return ListOf(new CompositeValue(values));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions