Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2012
    Posts
    30

    Question Unanswered: DB2 Text Search Questions

    Hi All!

    Using DB2 9.7.5 with DB2 Text Search + Net Search Extender (TS + NSE).

    1. How Select from DB2 text index all values that are matched by search key?

    F. e. text field contains phrase - Lorem Ipsum Ipsums. And you pass word - Ips. How get words - Ipsum, Ipsumsfrom text index?

    2. Can DB2 set text indices on view which is a snapshot of a table with text index?

    Thanks.

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    You should use CONTAINS, like in these examples:
    IBM DB2 9.7 Information Center for Linux, UNIX, and Windows
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    Oct 2012
    Posts
    30
    Quote Originally Posted by aflorin27 View Post
    You should use CONTAINS, like in these examples:
    IBM DB2 9.7 Information Center for Linux, UNIX, and Windows

    The CONTAINS Function will get the whole field from table, but i need only matched words in this field..

  4. #4
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    You may use % for character masking (IBM DB2 9.7 Information Center for Linux, UNIX, and Windows).

    In your example, you may try something like:
    SELECT id_column
    FROM your_table
    WHERE CONTAINS (your_text_column, '"%Ips%"') = 1
    to get the IDs of the rows that match your search key. You can then use these IDS to obtain the text field, parse it and display the words.
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  5. #5
    Join Date
    Oct 2012
    Posts
    30
    Quote Originally Posted by aflorin27 View Post
    You may use % for character masking (IBM DB2 9.7 Information Center for Linux, UNIX, and Windows).

    You can then use these IDS to obtain the text field, parse it and display the words.
    DB2 has native parsing function(s) with regex?

  6. #6
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    Quote Originally Posted by Black Moon View Post
    DB2 has native parsing function(s) with regex?
    I don't think so.
    For such a task I've used LOCATE + SUBSTR functions.
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  7. #7
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    DB2 doesn't supply a regexp function.
    But, you can include some UDFs easily,
    like the examples in here...
    Bringing the Power of Regular Expression Matching to SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •