redis-om-node icon indicating copy to clipboard operation
redis-om-node copied to clipboard

syntax error (stop word) when querying a field with a dot

Open waleedf112 opened this issue 1 year ago • 3 comments

The query to RediSearch had a syntax error: "Syntax error at offset 7 near objectId".\nThis is often the result of using a stop word in the query. Either change the query to not use a stop word or change the stop words in the schema definition. You can check the RediSearch source for the default stop words at: https://github.com/RediSearch/RediSearch/blob/master/src/stopwords.h.

here is my code:

await repository.search().where('user.objectId').equals(user.id).return.first();

this is the generated query:

repository.search().where('user.objectId').equals(user.id).return.query;
// (@user.objectId:{UPZ1HHj8WV})

I've tried to turn off the stop words, adding the dot to stop words, and resetting it to the defaults, but none have worked. this is the schema:

new Schema(ProfileEntity, {
            'objectId': { type: 'string', caseSensitive: true },
            'createdAt': { type: 'date', sortable: true },
            'updatedAt': { type: 'date', sortable: true },
            'name.ar': { type: 'string', caseSensitive: true },
            'name.en': { type: 'string', caseSensitive: true },
            'user.__type': { type: 'string', indexed: false },
            'user.className': { type: 'string', indexed: false },
            'user.objectId': { type: 'string', caseSensitive: true },
        }, {
            useStopWords: 'OFF',
            // stopWords: ['.', 'objectId', 'user', 'user.objectId'],
        });

any help is appreciated, thanks 😁.

waleedf112 avatar Aug 19 '22 11:08 waleedf112

I suspect the RediSearch doesn't like dots in field names. Might be that Redis OM needs to escape them somehow. Might be that they're not escapable and this is something that RediSearch can't handle. Regardless, sounds like a bug to me that needs looked into.

guyroyse avatar Aug 29 '22 15:08 guyroyse

This is fixable for the HASH data structure (where any non alphanumeric characters in the field name need to be escaped), but it doesn't look like it works for JSON format.

CaptainCodeman avatar Sep 27 '22 19:09 CaptainCodeman

That would make sense that it wouldn't work for JSON as it's probably taking the . and interpreting it as part of the JSONPath to the field.

guyroyse avatar Sep 30 '22 09:09 guyroyse