FirebirdSQL / firebird

Firebird server, client and tools
https://firebirdsql.org
1.26k stars 217 forks source link

Extend indexing feature to index multiple values, a little same as word index .. #8184

Open livius2 opened 4 months ago

livius2 commented 4 months ago

Currently, when we create an expression index, it must be a singleton function.

For example:

CREATE IXAE_TEST_VALUES ON TEST COMPUTED BY(CALC_SINGLE_VALUE(MY_FIELD));

However, if you need to divide a field into components such as words, numbers, etc., this is not possible.

For instance, consider a field with the value 'My salary is 10000 and it contains 500 for x and 700 for y.' If you need to index each number, or if you have the text 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' and need to index each word, you cannot do this without an external indexer like Lucene, or a helper table and procedure that divides the field into words. It complicate things which is not nescessary at all.

Please add the capability to index multiple values from the same field pointing to the same record.

For example:

CREATE IXAE_TEST_VALUES ON TEST COMPUTED BY(DIVIDE_VALUES_WITH_SUSSPED_PROC(MY_FIELD));

I believe this support is needed as you are planning to introduce JSON, which requires being indexable.

But you must think how to query by this values. Maybe some special word or syntax? Like SELECT * FROM TEST WHERE 'Lorem' IN MY_FIELD

aafemt commented 4 months ago

Encouraging denormalization seems like a bad idea to me.

livius2 commented 4 months ago

Encouraging denormalization seems like a bad idea to me.

How will you index JSON in the future? This idea is useful for many scenarios.