mikegoatly / lifti

A lightweight full text indexer for .NET
MIT License
184 stars 9 forks source link

Operaterrors as a text #90

Closed iduducohen closed 11 months ago

iduducohen commented 11 months ago

Is it possible to use operators or brackets as text? For ex : search for test & or test (

mikegoatly commented 11 months ago

Hi @iduducohen, At the moment the only way to do this is to manually construct the query yourself:

// First normalize the search text
var normalizedSearchText = index.DefaultTokenizer.Normalize("test (");

// Construct a query with a single query part
var query = new Query(new ExactWordQueryPart(normalizedSearchText));

// Execute the query
var results = index.Search(query);

I'm tracking issue #85 that will allow you to escape these characters.

iduducohen commented 11 months ago

Thank you very much for the quick reply, I will look into the matter. In addition, is it possible to perform NOT operations?

‫בתאריך יום ב׳, 18 בדצמ׳ 2023 ב-7:54 מאת ‪Mike Goatly‬‏ <‪ @.***‬‏>:‬

Hi @iduducohen https://github.com/iduducohen, At the moment the only way to do this is to manually construct the query yourself:

// First normalize the search textvar normalizedSearchText = index.DefaultTokenizer.Normalize("test ("); // Construct a query with a single query partvar query = new Query(new ExactWordQueryPart(normalizedSearchText)); // Execute the queryvar results = index.Search(query);

I'm tracking issue #85 https://github.com/mikegoatly/lifti/issues/85 that will allow you to escape these characters.

— Reply to this email directly, view it on GitHub https://github.com/mikegoatly/lifti/issues/90#issuecomment-1859602361, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOQBI4MR5MI2ULMG6TTQI3YJ7LBRAVCNFSM6AAAAABAYTNVQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGYYDEMZWGE . You are receiving this because you were mentioned.Message ID: @.***>

mikegoatly commented 11 months ago

No, not at the moment - that's a good feature request though. I'll create an issue to track that 😊.