Forum Stats

  • 3,815,724 Users
  • 2,259,072 Discussions
  • 7,893,216 Comments

Discussions

"+" special character problem with SYN operator

Muzy
Muzy Member Posts: 2 Red Ribbon
edited Jan 3, 2020 1:39PM in Text

Hi,

i wanted to crete a synonym for "ABC+" and "ABCPLUS". To achieve this i had to escape the "+" character with curly braces like this :

exec ctx_thes.create_relation('TEST_SYN', '{ABC+}', 'SYN', 'ABCPLUS');

When i run this query, i can see the synonym phrases "ABC+" and "ABCPLUS" :

SELECT * FROM ctx_thes_phrases where thp_phrase like 'ABC%';

But when i query it with SYN function ( that is also used in CONTAINS queries i think ), i don't get expected result.

select CTX_THES.SYN('{ABC+}', 'TEST_SYN') from dual;

Actual Result:

({ABC}&{}) | {ABCPLUS}

Expected Result:

{ABC+} | {ABCPLUS}

Because of this my contains query doesn't give me expected results. It seems that the SYN function evaluates "+" character as & (AND) operator.

To search within a domain index, i have also configure the domain index like this.

ctx_ddl.set_attribute(preference_name => 'LEXER_NAME', attribute_name  => 'printjoins', attribute_value => '+');

As a result, when i search for "ABC+" with synonyms, i get results with "ABC", because of the result of the SYN function : ({ABC}&{}) | {ABCPLUS}. And i don't want this.

select * from test_table

where CONTAINS(full_index,'SYN({ABC+},TEST_SYN)',0)>0;

Any ideas ?

Thanks.

Answers

  • chris227
    chris227 Member Posts: 3,517 Bronze Crown
    edited Jan 3, 2020 1:39PM

    Obviously the thesaurus didnt take any printjoins etc. defined into account.

    Furthermore if you take a look into the table ctxsys.dr$ths_phrase, you will probably find that three tokens are indexed, ABC+, ABCPLUS *and* ABC.

    The latter may be the reason for your unwanted result.

    Also more worse may be the error raised if queried the other way round:

    syn(ABCPLUS,TEST_SYN) leads to

    ERROR at line 1:

    ORA-29902: error in executing ODCIIndexStart() routine

    ORA-20000: Oracle Text error:

    DRG-50925: could not parse return value of PL/SQL

    DRG-50901: text query parser syntax error on line 1, column 19

    So being not able to overcome this issue by palying around with the thesaurus itself it might be worth to consider another approach.

    (I played around with ctx_thes.drop_phrase ('TEST_SYN', 'ABC'), but i seems not the correct idea to me).

    This approach might be to

    1. create a separate mapping table for synonyms

    2. write a pl/sql function that generates an approbiate search expression from the given search term by getting the relevant tokens using ctx_doc.tokens from the origin search term, replacing each occurence with an or-expression of the mappings if existing any and the mapped token itself (if wanted).

    3. taking the result as the search expression and abstain from syn totally.

    Regards

  • kutrovsky
    kutrovsky Member Posts: 23 Blue Ribbon

    Thanks for feedback. It's such a shame that syn functionality is not a bit more extensive.