redis-om-node
redis-om-node copied to clipboard
syntax error (stop word) when querying a field with a dot
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 😁.
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.
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.
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.