StackExchange / NRediSearch

Other
31 stars 9 forks source link

NRediSearch create index on hash prefix #2

Open rakhimzhanov opened 3 years ago

rakhimzhanov commented 3 years ago

Hi team,

Is there any way to create an index with prefix in the library NRediSearch like below? FT.CREATE idx:movie ON hash PREFIX 1 "movie:" SCHEMA title TEXT SORTABLE release_year

Example was used from this source

Regards, L

SCT-Shimazaki commented 3 years ago

I am having this exact question. I store objects of multiple classes so to say, and I need this "prefix" thing for Redisearch to work as expected.

mgravell commented 3 years ago

the PREFIX API is exposed in the NuGet version 2.2.11, via the IndexDefinition type

On Mon, 15 Mar 2021 at 10:19, Satoshi @.***> wrote:

I am having this exact question. I store objects of multiple classes so to say, and I need this "prefix" thing for Redisearch to work as expected.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StackExchange/StackExchange.Redis/issues/1683#issuecomment-799299910, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEHMBQCTJ2MIFLGIKLVSLTDXNJVANCNFSM4XKI2ZMA .

-- Regards,

Marc

SCT-Shimazaki commented 3 years ago

I read this thread and also found it out, thank you!

https://github.com/StackExchange/StackExchange.Redis/pull/1544

But how can I specify prefixes when adding documents?

A object of the IndexDefinitiontype can only go to ConfiguredIndexOptions, which will then be supplied only to CreateIndex() or its async counterpart. Not to AddDocument()

When you add a document you also need to specify the prefix so I think we need the ConfiguredIndexOptions as one of the parameters here too

mysterio21 commented 3 years ago

But how can I specify prefixes when adding documents?

If you are using AddDocumentAsync for example you can specify the docId parameter with the prefix, for example: movie:11002