StackExchange / NRediSearch

Other
31 stars 9 forks source link

Add support for `ON JSON` index type in RediSearch #23

Open gkorland opened 3 years ago

mgravell commented 3 years ago

any chance of an API reference here, or a "prior art" example of what this means?

AvitalFineRedis commented 3 years ago

Hi @mgravell This means you will be able to create a JSON doc which RediSearch will index.

Currently, RediSearch have:

FT.CREATE {index} [ON {structure}] … SCHEMA {field} …

Where: structure accepts only HASH, field is the name of the field in the HASH.

The syntax is modified as:

FT.CREATE {index} [ON {structure}] … SCHEMA {identifier} [AS {attribute}] …

Where: structure can be HASH or JSON. identifier is either: ON HASH: The field name of the HASH ON JSON: a JSONPath. attribute is the mapped name in RediSearch's index.

E.g.:

FT.CREATE idx ON JSON SCHEMA $.product.label AS label TEXT

By replacing the {field} part of the schema by {identifier} [AS {attribute}], a mapping logic is introduced, where a JSONPath is associated with an attribute name.