How will I know what search fuzzy matching word

I tried to find something about my problem, but research has resulted in no relevant thread. I do not use fuzzy to search text, but the names and I use it mainly to work even if the user misspelled the name of a resource.

In order to set the search I want to know what the fuzzy search word was actually and what was the outcome for this match.

So if I search for 'sumer' I get hit for "hot summer" and the relationship is clear. But if I get soon "swimming is not possible that the Summit ends" the blow is not clear more.

You can use fuzzy with weight and use the partition function for the score. You can use ctx_doc.highlight to get the positions (offsets and length) of the matching words and then use it in a function in pipeline to return these words and this function in your query. Please see the demo below.

-data and index table:

SCOTT@orcl_11gR2> CREATE TABLE test_tab
  2    (test_col  VARCHAR2(46))
  3  /

Table created.

SCOTT@orcl_11gR2> INSERT ALL
  2  INTO test_tab VALUES ('warm summer')
  3  INTO test_tab VALUES ('soon swimming is not possible as summit closes')
  4  INTO test_tab VALUES ('other data')
  5  SELECT * FROM DUAL
  6  /

3 rows created.

SCOTT@orcl_11gR2> CREATE INDEX test_idx
  2  ON test_tab (test_col)
  3  INDEXTYPE IS CTXSYS.CONTEXT
  4  /

Index created.

-function

SCOTT@orcl_11gR2> create or replace function get_words
  2    (p_idx          in varchar2,
  3       p_rid          in rowid,
  4       p_query      in varchar2,
  5       p_col          in varchar2)
  6    return          sys.odcivarchar2list
  7    authid          definer
  8    pipelined
  9  as
 10    v_hightab     ctx_doc.highlight_tab;
 11  begin
 12    ctx_doc.set_key_type ('rowid');
 13    ctx_doc.highlight (p_idx, p_rid, p_query, v_hightab);
 14    for i in 1 .. v_hightab.count loop
 15        pipe row
 16          (dbms_lob.substr
 17            (p_col,
 18             v_hightab(i).length,
 19             v_hightab(i).offset));
 20    end loop;
 21    return;
 22  end get_words;
 23  /

Function created.

SCOTT@orcl_11gR2> show errors
No errors.

-Research:

SCOTT@orcl_11gR2> VARIABLE search_string VARCHAR2(100)
SCOTT@orcl_11gR2> EXEC :search_string := 'sumer'

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> COLUMN words FORMAT A15
SCOTT@orcl_11gR2> SELECT SCORE(1), x.column_value words, t.test_col
  2  FROM   test_tab t,
  3           TABLE
  4             (get_words
  5            ('test_idx',
  6             t.ROWID,
  7             'FUZZY (?' || :search_string || ', 1, 5000, W)',
  8             t.test_col)) x
  9  WHERE  CONTAINS
 10             (t.test_col,
 11              'FUZZY (?' || :search_string || ', 1, 5000, W)',
 12              1) > 0
 13  ORDER  BY SCORE(1) DESC
 14  /

  SCORE(1) WORDS           TEST_COL
---------- --------------- ----------------------------------------------
        36 summer          warm summer
        12 summit          soon swimming is not possible as summit closes

2 rows selected.

Tags: Database

Similar Questions

Maybe you are looking for

  • Analysis tool ALM to drop the names of parameters

    Hello We use ALM (12.20) analytical tools to create reports of test cases and test steps details.  When we run the reports, all the parameter names in the test steps (e.g. >) are missing and only "" shows where is the name of the parameter. Someone k

  • Install Service Pack 3

    When you install Service Pack 3, on one of our computers he hangs up trying to intall ' BEETHOV9. WMA "and the only option is to cancel the intall.

  • 3ds Max falls down using Quadro 1000 M map on battery

    If I run 3ds Max 2012 on the 1000 M Quadro card with the power adapter is plugged in, it works fine. If I unplug the power supply while the program is running, or run the program under the power of the battery that the program will run for a few seco

  • How do I revert to my last (better) version of Adobe Acrobat 10

    How can I go back to my old version of Adobe?

  • private for Windows applications

    HelloI have to deploy and help DPS app in camera for windows, in the help page, for a public release of the Digital Publishing Solution documentation | Windows edition Guide to DPS 2015 is clear enough, but for private distribution, there more confus