Pb score function - DRG-50901

Hi all,
I get an error DRG-50901 :text query parser syntax error on line 1, column 1
when i use the score function
table DOCUMENT :
-FILE_ID
-FILE_NAME
-BLOB_CONTENT BLOB
-FILE_TYPE
-FILE_SIZE
the index code :
CREATE INDEX DOCUMENT_IDX ON DOCUMENT
(BLOB_CONTENT)
INDEXTYPE IS CTXSYS.CONTEXT
PARAMETERS('FILTER ctxsys.auto_filter SYNC (ON COMMIT)');
So the first query works well but the second does not !
1)
SELECT d.file_name
FROM document d
WHERE (contains (d.blob_content, '%' || TEXT_VALUE || '%', 1) > 0)
2)
SELECT d.file_name, score(1) as relevance
FROM document d
WHERE (contains (d.blob_content, '%' || TEXT_VALUE || '%', 1) > 0)
Can anybody help me to solve it?
Regards,
Gregory

I have not seen this problem before. Can you post a complete example and also include your release number?
Faisal

Similar Messages

  • Context search if char [ or ( is typed by mistake - error DRG-50901

    If the search string has [ or (, why doesn't context treat it as
    a part of the string? Do I have to do anything special to avoid
    the run time error -
    ORA-20000: interMedia Text error: DRG-50901: text query parser
    syntax error on line 1, column 13
    Thanks in advance
    Vidhya

    I found this
    http://technet.oracle.com/products/text/x/Tech_Overviews/imt_817.
    html
    But it does not work as I expect
    The CTXCAT Query Language
    Once the ctxcat index is created, you query using the operator
    catsearch
    instead of contains:
    select item_desc from auction
    where catsearch(item_desc, 'oracle', null)>0;
    This finds all rows in auction which have "oracle" in the
    item_desc text.
    Like contains, the first argument is the text column, and the
    second is the
    query string. The third argument we'll talk about below -- just
    ignore it
    for now. There is no score label argument, because catsearch
    does not
    provide scoring -- it is a simple boolean search.
    The catsearch operator uses a much simpler query language than
    contains,
    with the intent that web-style queries can be passed through to
    catsearch
    without extra parsing. The query language rules are:
    * Multiple words are treated as an AND.
    * Vertical bar is used for OR.
    * A leading plus sign on words is ignored and discarded
    * A leading minus sign excludes words (must have included
    words)
    * Double quotes delimit phrases.
    * Parentheses group operations.
    Or, in comparison:
    catearch Query Equivalent contains query
    A B A & B
    A | B A | B
    +A -B           A ~ B
    "A B" A B
    "A B" C (A B) & C
    (A B) | C (A & B) | C
    AND, OR, AND-NOT, and PHRASE are the only functions currently
    available in the
    catsearch query language. catsearch does not support any of the
    other
    features found in the context query language such as accum,
    within, fuzzy,
    stem, wildcard, thesaurus, near, etc.

  • DRG-50901 error cannot be reproduced to our test enviroments. Any ideas?

    We get the following error
    10:59:10,538#org.hibernate.util.JDBCExceptionReporter#ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    DRG-50901: text query parser syntax error on line 1, column 1
    From the logs we can see that the error was produced two times when the following keywords were searched:
    1) key
    2) doctoral
    In our test enviroments when we search those keywords we cannot reproduce the error.
    Also, we parse the search keywords doing what is described below:
    1) escape reserved characters with "/", e.g test { becomes test/{
    2) replace double quoted phrases with curly braces for exact match "test something" becomes {test something}
    3) escape reserved words and add commas between words in order to search all the words of a phrase e.g looking something becomes /looking,/something
    The exact query that runs and fails to the client is:
    SELECT rownum as id,
    x.* from (
    SELECT SCORE(1) score,
    ctx_doc.snippet('eqf_trans_ot_idx', et.EQF_TRANS_ID, '/key') as snippet
    FROM eqf_trans et
    WHERE 1 = 1
    AND contains(et.ORACLE_TEXT_COLUMN, '/key', 1) > 0)x
    WHERE ROWNUM<= 100;
    and
    SELECT rownum as id,
    x.* from (
    SELECT SCORE(1) score,
    ctx_doc.snippet('eqf_trans_ot_idx', et.EQF_TRANS_ID, '/doctoral') as snippet
    FROM eqf_trans et
    WHERE 1 = 1
    AND contains(et.ORACLE_TEXT_COLUMN, '/doctoral', 1) > 0)x
    WHERE ROWNUM<= 100;
    Any ideas why this may occur or how I can reproduce it???

    You get the following stack:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    DRG-50901: text query parser syntax error on line 1, column 1
    when there is just about any syntax error caused by your search string, such as searching for a reserved word or stop word or null value. From what you have supplied, that does not appear to be the case. However, there are some unusual things about your query. You say that you are using / to escape, but the escape character is \ not /. You have where 1=1 which suggests that you may be constructing and executing the query dynamically. You use rownum in an outer query, but have not ordered in the inner sub-query.
    I suspect that what you are running may be different from what you are posting and think you are running. You need to provide an actual copy and paste. It also helps if you include things like create table statement and insert statement for sample data, and create index statement. The various preferences in an index can make a big difference. You can use ctx_report.create_index_script to obtain and provide that.
    There is a chance that you have hit some sort of bug. You should provide your Oracle version and try to narrow the problem down by eliminating one thing at a time. For example if you can show that the query does not produce an error with "where contains ..." but produces an error with "where 1=1 and contains ..." then that is significant.

  • DRG-50901  Error

    Hi All
    I am using interMedia in Oracle 9i (9.2). with oracle FORM 6i
    I have a PL/SQL procedure with a ref cursor, which perform a fairly simple select for searching text. I got perfect result when I run it as stand alone query outside of the procedure. But when I call it from the form it wok for some search words, but give me error (DRG-50901 :text query parser syntax error on line 1, column 1) when I use certain words (tax, personal, property, tif) what I am doing wrong? Thanks in advance for your help.
    PROCEDURE cs_refcur(cs_data IN OUT cs_cursor, cs_criteria IN dpt.CS_CONTACT.subject%TYPE)
    IS
    BEGIN
    OPEN cs_data FOR SELECT cs_contact_id, subject, SCORE(1)+SCORE(2)
    SCORE(3)SCORE(4)+SCORE(5)+SCORE(6) AS score
    FROM dpt.CS_CONTACT
    WHERE CONTAINS(subject, 'ABOUT({'||cs_criteria||'})', 1) > 0
    OR CONTAINS(contact_org, 'ABOUT({'||cs_criteria||'})', 2) > 0
    OR CONTAINS(question, 'ABOUT({'||cs_criteria||'})', 3) > 0
    OR CONTAINS(answer, 'ABOUT({'||cs_criteria||'})', 4) > 0
    OR CONTAINS(reference, 'ABOUT({'||cs_criteria||'})', 5) > 0
    OR CONTAINS(citation, 'ABOUT({'||cs_criteria||'})', 6) > 0
    ORDER BY (SCORE(1)+SCORE(2)+SCORE(3)+SCORE(4)+SCORE(5)
    +SCORE(6)) DESC, 2;
    END cs_refcur;
    Thanks
    Ali

    This forum is for interMedia, image audio and video. Please post your question in the Oracle Text forum.
    Thank you.

  • DRG-50901: text query parser syntax error

    The query
    SELECT * FROM ij
    where
    CONTAINS (ij.summary, 'ATTENZIONE!') > 0 returns an error:
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    DRG-50901: text query parser syntax error on line 1, column 13
    Why?
    There is a TEXT index on the summary column:
    CREATE INDEX IJL_SUMMARY_IX ON IJ
    (SUMMARY)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS('
        lexer           MITO_LEXER
        wordlist        DEFAULT_WORDLIST
        stoplist        IJL_STOPLIST
        storage         IJL_TEXT_STORAGE
        SYNC (EVERY "SYSDATE + 10/1440")')
    PARALLEL ( DEGREE 4 INSTANCES 1 );where the MITO_LEXER is
    BEGIN
    CTX_DDL.create_preference ('mito_lexer', 'BASIC_LEXER');
    CTX_DDL.set_attribute ('mito_lexer', 'INDEX_STEMS', 'ITALIAN');
    -- MITO-318: search on Text Index for Asterisks
    CTX_DDL.set_attribute ('mito_lexer', 'printjoins', '*');
    END;
    /

    Because the exclamation mark ("!") is a reserved operator, meaning soundex, and must appear before the word it applies to.

  • How score() function works in HANA fuzzy search

    Hi, i am confused by the score() returned value when i use this in fuzzy search in HANA
    CREATE COLUMN TABLE test_similar_calculation_mode
    ( id INTEGER PRIMARY KEY, s text);
    INSERT INTO test_similar_calculation_mode VALUES ('1','stringg');
    INSERT INTO test_similar_calculation_mode VALUES ('2','string theory');
    INSERT INTO test_similar_calculation_mode VALUES ('3','this is a very very very long string');
    INSERT INTO test_similar_calculation_mode VALUES ('4','this is another very long string');
    SELECT TO_INT(SCORE()*100)/100 AS score, id, s FROM test_similar_calculation_mode WHERE CONTAINS(s, 'theory', FUZZY(0.9, 'similarCalculationMode=compare')) ORDER BY score DESC;
    the returned list is just as below
    SCORE      ID      S
    0.84            2       string theory
    why i assign 0.9 as threshold in fuzzy function while this line with score 0.84 also be returned.
    from my understanding, the S field is text data type, so the string actually is divided into seperate word list, so the score should be 1.0, is it right?
    any hints is very appreciate,thanks

    Hi William,
    By default the score() function returns a TF/IDF score for text data types.
    To get back the fuzzy score, you have to use the search option 'textSearch=compare' (or 'ts=compare'). Without other options, this gives an average score of all tokens ('string' and 'theory') and you get a score of 0.7 as a result.
    To ignore the additional token 'string' in the database, you have to specify another option that tells the score function to use the tokens from the user input only ('cnmt=input').
    So you should use
    TO_INT(SCORE()*100)/100 AS score, id, s
    FROM test_similar_calculation_mode
    WHERE CONTAINS(s, 'theory', FUZZY(0.9, 'scm=compare, ts=compare, cnmt=input'))
    ORDER BY score DESC;
    to get the expected results.
    Regards,
    Jörg

  • High score functionality via call to external server

    I have just packaged an existing Flash game as a test and literally just packaged it without making any changes whatsoever. The game included a top 100 score board which is populated by calling an asp page on an external server that returns xml data.
    I was most surprised that the high score functionality all worked when I tested the game on my iPhone i.e it displays the scores. I haven't tested submitting one yet though.
    I therefore wondered if this is allowed and if so is there any reason why this should be avoided. I have read there is something called Open Feint that allows you to do high scores.
    Any advice much appreciated.
    Thanks
    Paul

    Hi,
    where exactly is the FM crashing and why? Did you debug? Is it occuring at
    CALL FUNCTION 'FTP_CONNECT' DESTINATION RFC_DESTINATION
         EXPORTING USER = USER PWD = PASSWORD ACCT = ACCOUNT HOST = HOST
                   TRACE = FTP_TRACE GUSER = GATEWAY_USER
                   GPWD = GATEWAY_PASSWORD GHOST = GATEWAY_HOST
         IMPORTING HANDLE = HANDLE ERROR = CERROR
         EXCEPTIONS SYSTEM_FAILURE = 1 COMMUNICATION_FAILURE = 2.
    or earlier?
    Try tracing with ST01, one time with the way it works, and another time out of the WebDynpro where it crashes, then compare the logs.
    regards, Lukas

  • Audio to score function?

    Watched the Scott Wilkie Logic Pro tutorial and was trying to replace live drum sounds with the audio to score function. I may have gotten some of the steps wrong. I created a new instrument track and then went to the audio to score function and adjusted the velocity threshold. I processed the audio but I don't know if it processed. Now that I think of it I didn't see the midi score. Have anyone had any success doing this or know the steps. What window did Wilkie constrain the notes to a single pitch in? I guess he was doing it so fast.
    Thanks
    Greeneye

    put an empty midi track under the audio trak yor are trying to process. someties the midi track goes under the audio track you just converted, try dragging the aduio up/down to an adjacent empty track.. the midi track will be there. by fooling around with the levels, its fairly easy to create a replacement drum track. Use transform function to move all the midi notes to the proper trigger note you want.. Those will often end up on several different pitchs,
    once you get used to it, it is a very fast way to replace drum notes. it takes a little while, depending on length, and you will see a 'count down list' of notes to process.

  • **** snare flams using audio to score function!

    Hello,
    I've been using audio to score function to trigger snare samples from the ex24 to mix in with a recorded audio snare track.
    The problem is however the midi notes don't always exactly lock in with the audio resulting in random flams that I have to zoom in and move.
    Have I got the settings wrong for this? (I think I used the preset for drums-fast)
    Not sure if there is something I'm doing wrong, possibly the sensitivity?
    Thanks!

    You've got to play with the settings, and yes, I get flams too. You have to zoom in, and clean up the audio to score process. It's good, but not perfect.
    Superior has released a program called drum tracker , it will generate a midi file from an audio drumtrack file. It uses a series of filters to better pick out kik, hats, etc. It's better than Logic's, but Logic's function will still fill the bill (without having to spend extra $$$.
    In fact, you can set up a similar EQ filter, to help Logic improve it's recognition of kick, snares, hats, etc. Create a eq for each drum you want to detect. If you were replacing drums all day long, the Superior drum tracker would be a good investment. If you do it only occassionally, stick to Logic's 'audio to score' feature .

  • Average Score Function

    Hello.
    I have two things I need to do but I'm not sure how. These problems come up in my EVALUATION_RESULTS table. The first thing I need to do is create a formula for the primary key EVALUATION_ID. I need to do this so that it is the EMPLOYEE_NUMBER followed by EMPLOYER_NUMBER followed by EVALUATION_ID. For instance, if the employee being evaluated has the number 10000, the employer has the number 1000, and the evaluation ID is 100, the evaluation number should automatically be 100001000100. How can I have this be created automatically after the user completes a form?
    The second issue is: I need to create a function in the EVALUATION_RESULTS table that takes an average of four scores that are input in the form. So it will take (SCORE1+SCORE2+SCORE3+SCORE4)/4. How can I implement this so that the user enters the four scores, submits the form, and the AVERAGE_SCORE is added to the table.
    Thanks in advance for the help.
    Edited by: DanDan Sc on Jan 13, 2013 3:40 PM

    Hi Dan,
    your two requirements are probably not good ideas from a relational design point of view.
    I have two things I need to do but I'm not sure how. These problems come up in my EVALUATION_RESULTS table. The first thing I need to do is create a formula for the primary key EVALUATION_ID. I need to do this so that it is the EMPLOYEE_NUMBER followed by EMPLOYER_NUMBER followed by EVALUATION_ID. For instance, if the employee being evaluated has the number 10000, the employer has the number 1000, and the evaluation ID is 100, the evaluation number should automatically be 100001000100. How can I have this be created automatically after the user completes a form? Doing this is committing the error of overloading. This is where a single attribute contains information for more than one attribute. From a relational design point of view, the first thing you should be identifying from your list of attributes is the natural keys. In your case it may simply be the original evaluation id (100). If this is not unique, for example more than one employee or employer may share an evaluation id, then the natural key may be a combination of some or all of the attributes you have noted. In this case the natural key would be a combination of those attributes in what is called a composite key. From an implementation point of view, it may be quite acceptable to then create your Primary Key as a combination of those columns in a composite PK. Another implementation issue is that composite PK's can become unweildy to deal with, especially if they have to be referred to in different entities as Foreign Keys. In this case, you can change the composite PK to a Unique Key and create a single part PK which will be a number that is generated from a database object called a sequence. This is generally called an artificial key. If for some business reason you need to refer your original PK in the format you suggested, as in reports or business receipts, then is is a simple exercise to retrieve it from the database as you require it.
    The second issue is: I need to create a function in the EVALUATION_RESULTS table that takes an average of four scores that are input in the form. So it will take (SCORE1+SCORE2+SCORE3+SCORE4)/4. How can I implement this so that the user enters the four scores, submits the form, and the AVERAGE_SCORE is added to the table.Another principle of relational design is that you don't store anything in the database that can be derived from the existing data. Things like your average score should be calculated on the fly when ever your data is presented to the user in forms or reports.
    Regards
    Andre

  • Custom Score Function

    Experts,
    I want to perform a search on approx 200k records, all of 255 characters or less. For example, a user might enter "red hERring" and I'd like returned "Red herring", 100 for the term and score if an exact match is found. If a slight discrepancy say "herrings, red" is returned the score should be less, 0.8 for example. Further differences, such as "red hairing" should be further reduced to 0.55 (for example).
    To further complicate matters, I'd like to use the Thesaurus so that "red fish" would return a relatively high score of 0.75 or so.
    Is this available or would it need to be custom built?
    Many thanks in advance all!
    Phil

    Here is a simplified working example of what I think you are trying to do:
    scott@ORA92> CREATE TABLE customers
      2    (customer_id NUMBER,
      3       first_name  VARCHAR2(15),
      4       last_name   VARCHAR2(15),
      5       dummy         VARCHAR2(1),
      6       CONSTRAINT  customers_pk PRIMARY KEY (customer_id))
      7  /
    Table created.
    scott@ORA92> CREATE TABLE addresses
      2    (customer_id NUMBER,
      3       street         VARCHAR2(15),
      4       city         VARCHAR2(15),
      5       state         VARCHAR2(2),
      6       CONSTRAINT  addresses_fk FOREIGN KEY (customer_id)
      7                REFERENCES customers (customer_id))
      8  /
    Table created.
    scott@ORA92> CONNECT CTXSYS/ctxsys_password
    Connected.
    scott@ORA92> @ LOGIN
    scott@ORA92> SET ECHO OFF
    GLOBAL_NAME
    ctxsys@ORA92
    ctxsys@ORA92> CREATE OR REPLACE PROCEDURE concat_cols
      2    (p_rowid IN     ROWID,
      3       p_clob     IN OUT CLOB)
      4  AS
      5    v_clob            CLOB;
      6  BEGIN
      7    FOR c1 IN
      8        (SELECT customer_id, first_name || ' ' || last_name AS data
      9         FROM      scott.customers
    10         WHERE  ROWID = p_rowid)
    11    LOOP
    12        v_clob := v_clob || c1.data;
    13        FOR c2 IN
    14          (SELECT ' ' || street || ' ' || city || ' ' || state AS data
    15           FROM   scott.addresses a
    16           WHERE  a.customer_id = c1.customer_id)
    17        LOOP
    18          v_clob := v_clob || c2.data;
    19        END LOOP;
    20    END LOOP;
    21    p_clob := v_clob;
    22  END concat_cols;
    23  /
    Procedure created.
    ctxsys@ORA92> SHOW ERRORS
    No errors.
    ctxsys@ORA92> GRANT EXECUTE ON concat_cols TO scott
      2  /
    Grant succeeded.
    ctxsys@ORA92> CONNECT scott/tiger
    Connected.
    ctxsys@ORA92> @ LOGIN
    ctxsys@ORA92> SET ECHO OFF
    GLOBAL_NAME
    scott@ORA92
    scott@ORA92> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('concat_cols_datastore', 'USER_DATASTORE');
      3    CTX_DDL.SET_ATTRIBUTE ('concat_cols_datastore', 'PROCEDURE', 'concat_cols');
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    scott@ORA92> CREATE INDEX customer_text_idx ON customers (dummy)
      2  INDEXTYPE IS CTXSYS.CONTEXT
      3  PARAMETERS ('datastore concat_cols_datastore')
      4  /
    Index created.
    scott@ORA92> CREATE OR REPLACE TRIGGER taiud_customer
      2    AFTER INSERT OR DELETE OR UPDATE ON customers
      3  DECLARE
      4    v_job NUMBER;
      5  BEGIN
      6    IF DELETING THEN
      7        DBMS_JOB.SUBMIT
      8          (v_job,
      9           'ctx_ddl.optimize_index (''CUSTOMER_TEXT_IDX'',''FULL'');',
    10           SYSDATE);
    11    ELSE
    12        DBMS_JOB.SUBMIT
    13          (v_job,
    14           'ctx_ddl.sync_index (''CUSTOMER_TEXT_IDX'');',
    15           SYSDATE);
    16    END IF;
    17  END taiud_customer;
    18  /
    Trigger created.
    scott@ORA92> SHOW ERRORS
    No errors.
    scott@ORA92> INSERT ALL
      2  INTO customers VALUES (1, 'Bob', 'Smith', NULL)
      3  INTO customers VALUES (2, 'Bob', 'Jones', NULL)
      4  SELECT * FROM DUAL
      5  /
    2 rows created.
    scott@ORA92> INSERT ALL
      2  INTO addresses VALUES (1, 'Noplace', 'Nowhere', 'CA')
      3  INTO addresses VALUES (2, 'Smith St.', 'Somewhere', 'CA')
      4  SELECT * FROM DUAL
      5  /
    2 rows created.
    scott@ORA92> COMMIT
      2  /
    Commit complete.
    scott@ORA92> EXEC DBMS_LOCK.SLEEP (15)
    PL/SQL procedure successfully completed.
    scott@ORA92> SELECT token_text FROM dr$customer_text_idx$i
      2  /
    TOKEN_TEXT
    BOB
    CA
    JONES
    NOPLACE
    NOWHERE
    SMITH
    SOMEWHERE
    ST
    8 rows selected.
    scott@ORA92> VARIABLE g_words VARCHAR2(30)
    scott@ORA92> EXEC :g_words := 'Bob Smith'
    PL/SQL procedure successfully completed.
    scott@ORA92> SELECT   SCORE (1) * 3 + SCORE (2) * 2 + SCORE (3) * 1 AS score,
      2             c.first_name, c.last_name, a.street, a.city
      3  FROM     customers c, addresses a,
      4             (SELECT     LTRIM (RTRIM (REPLACE (REPLACE (REPLACE (:g_words,
      5                 '    ', ' '), '   ', ' '), '  ', ' '))) AS words
      6              FROM     DUAL) t2
      7  WHERE    c.customer_id = a.customer_id
      8  AND      (CONTAINS (C.dummy, t2.words, 1) > 0
      9  OR       CONTAINS (C.dummy,
    10                 'NEAR(($' || REPLACE (t2.words, ' ', ',$') || '),1)',
    11                 2) > 0
    12  OR       CONTAINS (c.dummy,
    13                 '!' || REPLACE (t2.words, ' ', ' AND !'), 3) > 0)
    14  ORDER BY 1 DESC
    15  /
         SCORE FIRST_NAME      LAST_NAME       STREET          CITY
            40 Bob             Smith           Noplace         Nowhere
            31 Bob             Jones           Smith St.       Somewhere
    scott@ORA92> UPDATE customers
      2  SET    last_name = 'Williams',
      3           dummy = dummy
      4  WHERE  last_name = 'Smith'
      5  /
    1 row updated.
    scott@ORA92> UPDATE customers
      2  SET    dummy = dummy
      3  WHERE  customer_id IN
      4           (SELECT customer_id
      5            FROM   addresses
      6            WHERE  city = 'Somewhere')
      7  /
    1 row updated.
    scott@ORA92> UPDATE addresses
      2  SET    city = 'Williams'
      3  WHERE  city = 'Somewhere'
      4  /
    1 row updated.
    scott@ORA92> COMMIT
      2  /
    Commit complete.
    scott@ORA92> EXEC DBMS_LOCK.SLEEP (15)
    PL/SQL procedure successfully completed.
    scott@ORA92> SELECT token_text FROM dr$customer_text_idx$i
      2  /
    TOKEN_TEXT
    BOB
    CA
    JONES
    NOPLACE
    NOWHERE
    SMITH
    SOMEWHERE
    ST
    BOB
    CA
    JONES
    NOPLACE
    NOWHERE
    SMITH
    ST
    WILLIAMS
    16 rows selected.
    scott@ORA92> VARIABLE g_words VARCHAR2(30)
    scott@ORA92> EXEC :g_words := 'Bob Williams'
    PL/SQL procedure successfully completed.
    scott@ORA92> SELECT   SCORE (1) * 3 + SCORE (2) * 2 + SCORE (3) * 1 AS score,
      2             c.first_name, c.last_name, a.street, a.city
      3  FROM     customers c, addresses a,
      4             (SELECT     LTRIM (RTRIM (REPLACE (REPLACE (REPLACE (:g_words,
      5                 '    ', ' '), '   ', ' '), '  ', ' '))) AS words
      6              FROM     DUAL) t2
      7  WHERE    c.customer_id = a.customer_id
      8  AND      (CONTAINS (C.dummy, t2.words, 1) > 0
      9  OR       CONTAINS (C.dummy,
    10                 'NEAR(($' || REPLACE (t2.words, ' ', ',$') || '),1)',
    11                 2) > 0
    12  OR       CONTAINS (c.dummy,
    13                 '!' || REPLACE (t2.words, ' ', ' AND !'), 3) > 0)
    14  ORDER BY 1 DESC
    15  /
         SCORE FIRST_NAME      LAST_NAME       STREET          CITY
            43 Bob             Williams        Noplace         Nowhere
             3 Bob             Jones           Smith St.       Williams
    scott@ORA92>

  • How Fuzzy score and Score() function works in HANA?

    Hi,
    I read fuzzy developer guide of HANA, but i am not getting how HANA calculate score() and fuzzy score?
    As per developer guide, Score() is calculate using TF/IDF, and I also try to calculate TF/IDF as per WIKI page, but it gives different values. and Score() value is changed as per x value of fuzzy(x) .
    See example
    select score() as sc, *
    from COMPANIES2
    where contains(Companyname,'IBM',fuzzy(0.7))
    it returns
    SC;                             ID; COMPANYNAME;  CONTACT
    0.7599999904632568;   6;  IBM Corp;               M. Master
    and for
    select score() as sc, *
    from COMPANIES2
    where contains(Companyname,'IBM',fuzzy(0.2))
    it return
    SC;                               ID;  COMPANYNAME;       CONTACT
    0.16945946216583252;   2;   SAP in Walldorf Corp;  Master Mister
    0.8392000198364258;     6;   IBM Corp;                   M. Master
    and table content of Companies2 is
    ID; Companyname;           contact
    1;  SAP Corp;                   Mister Master
    2;  SAP in Walldorf Corp;   Master Mister
    3;  ASAP;                         Nister Naster
    4;  ASAP Corp;                 Mixter Maxter
    5;  BSAP orp;                   Imster Marter
    6;  IBM Corp;                    M. Master
    Please provide any formula or algorithm for above.
    Thanks,
    Somnath A. Kadam

    Hi Somnath,
    It seems that the column "Companyname" has data type "SHORTTEXT" and here is the quote from SAP HANA Developer Guide Ch. 10.2.4.8 (p659)
    "Text types support a more sophisticated kind of fuzzy search. Texts are tokenized (split into terms), and the fuzzy comparison is performed term by term.
    When searching with 'SAP' for example, a record like 'SAP Deutschland AG & Co. KG' gets a high score, because the term 'SAP' exists in both texts. A record like 'SAPPHIRE NOW Orlando' gets a lower score, because 'SAP' is just a part of the longer term 'SAPPHIRE' (3 of 8 characters match)."
    So for text columns the score calculation is much more complex than tf-idf.
    As for the different fuzzy score, there is an explanation in the FAQ section ( Ch. 10.2.4.14, p736 "Is the score between request and result always stable for TEXT columns?")
    Basically, for each token, its similarity score will be used to calculate the overall result only if it is higher than the threshold given in fuzzy(). Any token with a lesser similarity score will be excluded. Therefore, slight change in the threshold may influence the overall score greatly.
    Here is an example.
    I added id 7 "SAP ASAP" to the data you used.
    Note that the similarity score between "ASAP" and "BSAP" is slightly over 0.74 and similarity score between "SAP" and "BSAP" is 0.75:
    For
        select score() as sc, * from COMPANIES2  where contains(COMPANYNAME,'BSAP',fuzzy(0.74))
    We get:
    <...omitted...>
    0.7474510073661804;    7;    SAP ASAP;        M. Master
    Now change the  threshold to 0.75 and the result is:
    <...omitted...>
    0.5588234663009644;    7;    SAP ASAP;        M. Master
    ID 7 now gets a lower score because "ASAP" is excluded and only "SAP" is used to calculate the overall result.
    As for tf-idf, it is used in the so-called freestyle search across multiple columns.
    An example from the same guide:
         select score() as sc, * from companies2 where contains((companyname,contact), 'IBM Master', FUZZY(0.7));
    Result:
    0.8103122115135193;    6;    IBM Corp;    M. Master
    Regards
    Roger Tao

  • Best way to add a score to a score box and total it up.

    I am creating a game for children to make good food choices
    for breakfast, lunch, dinner, and snacks. I need to have the food
    choice add a value to a score box when clicked onto the plate and
    subtract the same amount when clicked off. So far, all I have been
    able to do is get the score to appear in the upper left hand
    corner. When I can get the pancakes working properly, I will be
    adding other foods which will do the same thing with different
    numbers. The total score cannot go over 100. I am attaching the .as
    code, but it is separate from the .fla and I'm not sure if I can
    upload the .fla here.

    That worked! Now, I have another problem I can't seem to
    figure out--when I add another food, berries, all it is doing is
    moving the pancakes and not itself! Here is the revised coding:
    package
    //import any class being used by this package
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.events.MouseEvent;
    public class MealGame extends MovieClip
    //altered version
    var offPlate:Boolean; //variable for food off the plate
    var gameScore:int = 0;
    public function MealGame()
    //Create a score field for the pancakes.
    var gameScoreField:TextField = new TextField();
    // set the position values
    gameScoreField.x = 445;
    gameScoreField.y = 530;
    //Show the score field
    addChild(gameScoreField);
    var tf:TextFormat = new TextFormat();
    var scoreBox:Object = getChildAt(numChildren-1);
    //scoreBox.x = 445;
    //scoreBox.y = 530;
    //Create a new instance of the meal class.
    var pancakes1:Pancakes = new Pancakes();
    var berries1:Berries = new Berries();
    //Display the food on this stage.
    this.addChild(pancakes1);
    this.addChild(berries1);
    //Position the food item.
    pancakes1.x = 11;
    pancakes1.y = 42;
    berries1.x = 211;
    berries1.y = 396;
    offPlate = true;
    //make the food item a button
    pancakes1.buttonMode = true;
    pancakes1.addEventListener(MouseEvent.CLICK, onClick);
    berries1.buttonMode = true;
    berries1.addEventListener(MouseEvent.CLICK, onClick);
    //toggle the food item to put on plate or off the plate
    //toggle adding to the score or removing from the score
    function onClick(event:MouseEvent):void
    if(offPlate)
    pancakes1.x = 119;
    pancakes1.y = 380;
    berries1.x = 515;
    berries1.y = 55;
    //add to score
    gameScore = gameScore + 50;
    gameScoreField.text = " " + String(gameScore);
    tf.font = "Arial";
    tf.bold = true;
    tf.color = 0x000000;
    tf.size = 32;
    //Take this text formatting object; apply it to the
    textfield
    gameScoreField.setTextFormat(tf);
    //toggle the offPlate value
    offPlate = !offPlate;
    else
    pancakes1.x = 11;
    pancakes1.y = 42;
    //berries1.x = 211;
    //berries1.y = 396;
    //remove from score
    gameScore = gameScore - 50;
    gameScoreField.text = " " + String(gameScore);
    tf.font = "Arial";
    tf.bold = true;
    tf.color = 0x000000;
    tf.size = 32;
    //tf.x = 426;
    //Take this text formatting object; apply it to the
    textfield
    gameScoreField.setTextFormat(tf);
    offPlate = !offPlate;
    }

  • Using SCORE on top of View with UNION

    Hi guys,
    I explain what I'm trying to do quickly:
    2 Tables: table1 and table2 with same structure and both have a multi_column_datastore ctxsys.context.
    1 View: view1
    select * from table1
    union
    select * from table2
    if I run:
    select * from view1 WHERE contains(view1.COLUMN1,'%textext%',1 ) > 0;
    this works fine, I get the correct result.
    If I try to use SCORE function I have an error:
    select * from view1 WHERE contains(view1.COLUMN1,'%textext%',1 ) > 0 ORDER by SCORE(1);
    ORA-29921: Ancillary operator not supported with set view query block
    I understand the problem is in the UNION inside the view,is there any way to make it works keep filtering the VIEW?
    Thanks in advance

    There is no score in the view, so you can't reference the score when querying the view.  In order to put the score in the view, you need a contains clause, which requires a value.  One method of doing this is to use sys_context.  Please see the reproduction of the problem and solution below.
    SCOTT@orcl12c> -- reproduction of problem:
    SCOTT@orcl12c> create table table1
      2    (column1  varchar2(30))
      3  /
    Table created.
    SCOTT@orcl12c> insert into table1 values ('textext')
      2  /
    1 row created.
    SCOTT@orcl12c> create table table2
      2    (column1 varchar2(30))
      3  /
    Table created.
    SCOTT@orcl12c> insert into table2 values ('textext')
      2  /
    1 row created.
    SCOTT@orcl12c> begin
      2    ctx_ddl.create_preference ('test_ds', 'multi_column_datastore');
      3    ctx_ddl.set_attribute ('test_ds', 'columns', 'column1');
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> create index table1_idx on table1 (column1)
      2  indextype is ctxsys.context
      3  parameters ('datastore  test_ds')
      4  /
    Index created.
    SCOTT@orcl12c> create index table2_idx on table2 (column1)
      2  indextype is ctxsys.context
      3  parameters ('datastore  test_ds')
      4  /
    Index created.
    SCOTT@orcl12c> create or replace view view1
      2  as
      3  select * from table1
      4  union
      5  select * from table2
      6  /
    View created.
    SCOTT@orcl12c> select * from view1 where contains (view1.column1, '%textext%', 1) > 0
      2  /
    COLUMN1
    textext
    1 row selected.
    SCOTT@orcl12c> select * from view1 where contains (view1.column1,'%textext%',1 ) > 0 order by score(1)
      2  /
    select * from view1 where contains (view1.column1,'%textext%',1 ) > 0 order by score(1)
    ERROR at line 1:
    ORA-29921: Ancillary operator not supported with set view query block
    SCOTT@orcl12c> -- solution:
    SCOTT@orcl12c> create or replace view view1
      2  as
      3  select score(1) score, table1.* from table1
      4  where  contains (table1.column1, sys_context ('text_query', 'query_value'), 1) > 0
      5  union
      6  select score(1) score, table2.* from table2
      7  where  contains (table2.column1, sys_context ('text_query', 'query_value'), 1) > 0
      8  /
    View created.
    SCOTT@orcl12c> create or replace context text_query using text_proc
      2  /
    Context created.
    SCOTT@orcl12c> create or replace procedure text_proc
      2    (p_val in varchar2)
      3  as
      4  begin
      5    dbms_session.set_context ('text_query', 'query_value', p_val);
      6  end text_proc;
      7  /
    Procedure created.
    SCOTT@orcl12c> exec text_proc ('%textext%')
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> set autotrace on explain
    SCOTT@orcl12c> select * from view1 order  by score
      2  /
         SCORE COLUMN1
             3 textext
    1 row selected.
    Execution Plan
    Plan hash value: 4090246122
    | Id  | Operation                       | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |            |     2 |    60 |     8   (0)| 00:00:01 |
    |   1 |  SORT ORDER BY                  |            |     2 |    60 |     8   (0)| 00:00:01 |
    |   2 |   VIEW                          | VIEW1      |     2 |    60 |     8   (0)| 00:00:01 |
    |   3 |    SORT UNIQUE                  |            |     2 |    58 |     8  (50)| 00:00:01 |
    |   4 |     UNION-ALL                   |            |       |       |            |          |
    |   5 |      TABLE ACCESS BY INDEX ROWID| TABLE1     |     1 |    29 |     4   (0)| 00:00:01 |
    |*  6 |       DOMAIN INDEX              | TABLE1_IDX |       |       |     4   (0)| 00:00:01 |
    |   7 |      TABLE ACCESS BY INDEX ROWID| TABLE2     |     1 |    29 |     4   (0)| 00:00:01 |
    |*  8 |       DOMAIN INDEX              | TABLE2_IDX |       |       |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       6 - access("CTXSYS"."CONTAINS"("TABLE1"."COLUMN1",SYS_CONTEXT('text_query','query_v
                  alue'),1)>0)
       8 - access("CTXSYS"."CONTAINS"("TABLE2"."COLUMN1",SYS_CONTEXT('text_query','query_v
                  alue'),1)>0)
    Note
       - dynamic statistics used: dynamic sampling (level=2)
    SCOTT@orcl12c>

  • Returning Count of Matching Words Rather than Score

    I'm using the SCORE function that will return a number representing the relevance of the matching search result; however, what the users really want is a COUNT of the number of search results returned within the document. For a search on the word "cat" this would return the number of times the word "cat" appears in the document. Ideally, if the user searched for "(dog and cat) within sentence", the COUNT would be of the number of times both dog and cat occur within sentences in the document; however, it would be acceptable to count the number of matching words in the document individually.
    Does Oracle Text have any way to return this COUNT directly within the results Oracle Text query? I can use a CTX_DOC.MARKUP call to mark the document up and the count the instances of the markup strings, but that's going to be a lot slower than if Oracle supports this out-of-the-box on the original query syntax.

    Yes (in 10g onwards), you need to use a query template with <score algorithm="COUNT"/>
    See here:
    http://www.oracle.com/technology/products/text/x/10g_tech_overview.html#qry_cscore
    Though the example there is a bit confusing since it has algorithm="SCORE" - the option for normal scoring.

Maybe you are looking for