redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.07k stars 108 forks source link

Tags separators are not copied when OM rebuilds the index #488

Open mortensi opened 1 year ago

mortensi commented 1 year ago

In the following test, I create an index with:

$.tags TAG SEPARATOR ","

But OM rewrites it using |.

(AFAIU the default separator is not |, but , in any case).

"SEPARATOR defaults to a comma (,), and can be any printable ASCII character." From https://redis.io/docs/stack/search/reference/tags/

Here's my index creation:

FT.CREATE document_idx ON JSON PREFIX 1 keybase:kb SCHEMA $.name TEXT $.content TEXT $.creation NUMERIC SORTABLE $.update NUMERIC SORTABLE $.state TAG $.owner TEXT $.processable TAG $.tags TAG SEPARATOR "," $.category TAG

127.0.0.1:6379> FT.INFO document_idx
 1) index_name
 2) document_idx
 3) index_options
 4) (empty array)
 5) index_definition
 6) 1) key_type
    2) JSON
    3) prefixes
    4) 1) keybase:kb
    5) default_score
    6) "1"
 7) attributes
 8) 1) 1) identifier
       2) $.name
       3) attribute
       4) $.name
       5) type
       6) TEXT
       7) WEIGHT
       8) "1"
    2) 1) identifier
       2) $.content
       3) attribute
       4) $.content
       5) type
       6) TEXT
       7) WEIGHT
       8) "1"
    3) 1) identifier
       2) $.creation
       3) attribute
       4) $.creation
       5) type
       6) NUMERIC
       7) SORTABLE
    4) 1) identifier
       2) $.update
       3) attribute
       4) $.update
       5) type
       6) NUMERIC
       7) SORTABLE
    5) 1) identifier
       2) $.state
       3) attribute
       4) $.state
       5) type
       6) TAG
       7) SEPARATOR
       8) 
    6) 1) identifier
       2) $.owner
       3) attribute
       4) $.owner
       5) type
       6) TEXT
       7) WEIGHT
       8) "1"
    7) 1) identifier
       2) $.processable
       3) attribute
       4) $.processable
       5) type
       6) TAG
       7) SEPARATOR
       8) 
    8) 1) identifier
       2) $.tags
       3) attribute
       4) $.tags
       5) type
       6) TAG
       7) SEPARATOR
       8) ,
    9) 1) identifier
       2) $.category
       3) attribute
       4) $.category
       5) type
       6) TAG
       7) SEPARATOR
       8) 
 9) num_docs
10) "0"
11) max_doc_id
12) "0"
13) num_terms
14) "0"
15) num_records
16) "0"
17) inverted_sz_mb
18) "0"
19) vector_index_sz_mb
20) "0"
21) total_inverted_index_blocks
22) "1"
23) offset_vectors_sz_mb
24) "0"
25) doc_table_size_mb
26) "0"
27) sortable_values_size_mb
28) "0"
29) key_table_size_mb
30) "0"
31) records_per_doc_avg
32) "nan"
33) bytes_per_record_avg
34) "nan"
35) offsets_per_term_avg
36) "nan"
37) offset_bits_per_record_avg
38) "nan"
39) hash_indexing_failures
40) "0"
41) indexing
42) "0"
43) percent_indexed
44) "1"
45) gc_stats
46)  1) bytes_collected
     2) "0"
     3) total_ms_run
     4) "0"
     5) total_cycles
     6) "0"
     7) average_cycle_time_ms
     8) "nan"
     9) last_run_time_ms
    10) "0"
    11) gc_numeric_trees_missed
    12) "0"
    13) gc_blocks_denied
    14) "0"
47) cursor_stats
48) 1) global_idle
    2) (integer) 0
    3) global_total
    4) (integer) 0
    5) index_capacity
    6) (integer) 128
    7) index_total
    8) (integer) 0

Here's how OM rewrites the index:

1677772267.249488 [0 [::1]:57336] "ft.create" "document_idx" "ON" "JSON" "PREFIX" "1" "keybase:json:" "SCHEMA" "$.pk" "AS" "pk" "TAG" "SEPARATOR" "|" "$.name" "AS" "name" "TAG" "SEPARATOR" "|" "$.name" "AS" "name_fts" "TEXT" "$.content" "AS" "content" "TAG" "SEPARATOR" "|" "$.content" "AS" "content_fts" "TEXT" "$.creation" "AS" "creation" "NUMERIC" "$.last" "AS" "last" "NUMERIC" "$.tags" "AS" "tags" "TAG" "SEPARATOR" "|" "$.category" "AS" "category" "TAG" "SEPARATOR" "|" "$.processable" "AS" "processable" "NUMERIC" "$.state" "AS" "state" "TAG" "SEPARATOR" "|" "$.author" "AS" "author" "TAG" "SEPARATOR" "|" "$.owner" "AS" "owner" "TAG" "SEPARATOR" "|" "$.versions[*].pk" "AS" "versions_pk" "TAG" "SEPARATOR" "|" "$.versions[*].last" "AS" "versions_last" "TAG" "SEPARATOR" "|"

127.0.0.1:6379> FT.INFO document_idx
 1) index_name
 2) document_idx
 3) index_options
 4) (empty array)
 5) index_definition
 6) 1) key_type
    2) JSON
    3) prefixes
    4) 1) keybase:json:
    5) default_score
    6) "1"
 7) attributes
 8)  1) 1) identifier
        2) $.pk
        3) attribute
        4) pk
        5) type
        6) TAG
        7) SEPARATOR
        8) |
     2) 1) identifier
        2) $.name
        3) attribute
        4) name
        5) type
        6) TAG
        7) SEPARATOR
        8) |
     3) 1) identifier
        2) $.name
        3) attribute
        4) name_fts
        5) type
        6) TEXT
        7) WEIGHT
        8) "1"
     4) 1) identifier
        2) $.content
        3) attribute
        4) content
        5) type
        6) TAG
        7) SEPARATOR
        8) |
     5) 1) identifier
        2) $.content
        3) attribute
        4) content_fts
        5) type
        6) TEXT
        7) WEIGHT
        8) "1"
     6) 1) identifier
        2) $.creation
        3) attribute
        4) creation
        5) type
        6) NUMERIC
     7) 1) identifier
        2) $.last
        3) attribute
        4) last
        5) type
        6) NUMERIC
     8) 1) identifier
        2) $.tags
        3) attribute
        4) tags
        5) type
        6) TAG
        7) SEPARATOR
        8) |
     9) 1) identifier
        2) $.category
        3) attribute
        4) category
        5) type
        6) TAG
        7) SEPARATOR
        8) |
    10) 1) identifier
        2) $.processable
        3) attribute
        4) processable
        5) type
        6) NUMERIC
    11) 1) identifier
        2) $.state
        3) attribute
        4) state
        5) type
        6) TAG
        7) SEPARATOR
        8) |
    12) 1) identifier
        2) $.author
        3) attribute
        4) author
        5) type
        6) TAG
        7) SEPARATOR
        8) |
    13) 1) identifier
        2) $.owner
        3) attribute
        4) owner
        5) type
        6) TAG
        7) SEPARATOR
        8) |
    14) 1) identifier
        2) $.versions[*].pk
        3) attribute
        4) versions_pk
        5) type
        6) TAG
        7) SEPARATOR
        8) |
    15) 1) identifier
        2) $.versions[*].last
        3) attribute
        4) versions_last
        5) type
        6) TAG
        7) SEPARATOR
        8) |
 9) num_docs
10) "0"
11) max_doc_id
12) "0"
13) num_terms
14) "0"
15) num_records
16) "0"
17) inverted_sz_mb
18) "0"
19) vector_index_sz_mb
20) "0"
21) total_inverted_index_blocks
22) "1"
23) offset_vectors_sz_mb
24) "0"
25) doc_table_size_mb
26) "0"
27) sortable_values_size_mb
28) "0"
29) key_table_size_mb
30) "0"
31) records_per_doc_avg
32) "nan"
33) bytes_per_record_avg
34) "nan"
35) offsets_per_term_avg
36) "nan"
37) offset_bits_per_record_avg
38) "nan"
39) hash_indexing_failures
40) "0"
41) indexing
42) "0"
43) percent_indexed
44) "1"
45) gc_stats
46)  1) bytes_collected
     2) "0"
     3) total_ms_run
     4) "0"
     5) total_cycles
     6) "0"
     7) average_cycle_time_ms
     8) "nan"
     9) last_run_time_ms
    10) "0"
    11) gc_numeric_trees_missed
    12) "0"
    13) gc_blocks_denied
    14) "0"
47) cursor_stats
48) 1) global_idle
    2) (integer) 0
    3) global_total
    4) (integer) 0
    5) index_capacity
    6) (integer) 128
    7) index_total
    8) (integer) 0