ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SQL Full Text Search on AS400 Database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL Full Text Search on AS400 Database

    I have to rewrite the search box on our corporate website, and want to use something similar to what the search engines use to find records that "best" match a string.

    The existing version of the program (written in Websmart ILE) uses more than 20 SQL statements to try and match various combinations of up to 6 words, and aside from this being horribly inefficient, I really don't want to write it this way. The search is to be on our Product file, which already has an index that contains all the keywords to search on.

    I spent hours Googling yesterday, and it seems that only some SQL versions allow a Full Text search to be performed.

    One version is MySQL, and this only works on MyISAM tables. So, I could create a table in MySQL, which would contain exactly the same data as the Product Index, but would be easily searchable.

    This means extra work to create the database/table, which is then messy to maintain and access from RPG because it's in MySQL. However I do believe this would work.

    I did read that IBM have DB2 Text Extenders that allow you to do full text searches, but it seems this is only to allow you to index text documents on the IFS and to search them.

    It might be possible to create a single text document that contained all the index data, or maybe I would have to create a text document for each product. Either way it's a lot of overhead.

    What I want to do is to take a search phrase (for example "1mm wire strippers and cutters") and to return the best matches.

    Any thoughts? I know that very often having searched Google to death, by posting an article you then come across something helpful on your own, so forgive my indulgence in posting! I really would have hoped that IBM had some way of doing a search for a phrase.

    ----------------

    I should maybe add that our web pages are built on the fly, not fixed and stored in a folder. I did come across something called "AS400 Webserver Search Engine" which searches folders, but what we need is just a way of searching for a phrase in an AS400 file.
    Poddys Rambles On

  • #2
    Re: SQL Full Text Search on AS400 Database

    take a look at IBM's OMNIFIND software (it's free if you have SQL) you'll have to do some config work, etc but it should do what you're asking (or at least reasonably close)
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: SQL Full Text Search on AS400 Database

      For information about the OMNIFIND Text Search Utility, you may check the following link:

      IBM i - e-business and Web serving
      OmniFind Text Search Server for DB2 for i - 7.1


      Birgitta

      Comment


      • #4
        Re: SQL Full Text Search on AS400 Database

        Thanks Tom and Birgitta.

        I was just reading up on Omnifind and I think it should do the trick.

        It looks like we may already have this, or at least STRSQL doesn't tell me that the following is not a valid SQL statement:

        SELECT sekstr FROM b2csekpf WHERE contains(sekstr,'screwdriver') = 1

        However, I keep getting the following error, no matter what I try:

        Character conversion between CCSID 1208 and CCSID 65535 not valid.

        The AS400 is set to CCSID 65535 as is the session when I created the file. I can see that CCSID 1208 is UTF-8 but have no idea why SQL thinks anything is 1208, unless it's because this is a text search.

        The file contains just 2 fields, the first is a 5 digit key, the second is a 500 varchar field.

        So I am getting somewhere, but hit a brick wall unless I can resolve the CCSID conflict.

        I recreated the file, even changed the text field to a fixed length, but it made no difference.

        A regular SELECT worked ok though, so maybe the 1208 is related to using CONTAINS.
        Poddys Rambles On

        Comment


        • #5
          Re: SQL Full Text Search on AS400 Database

          Ahhhhhhh I see the following in the Omnifind documentation right near the top.

          A text index can be created over any CHAR, VARCHAR, CLOB, BLOB, DBCLOB, GRAPHIC,
          VARGRAPHIC, BINARY, or VARBINARY column which contains plain text, HTML, XML, or many rich
          document types (such as PDF files). The data is read from the text column and is converted to Unicode
          (CCSID 1208) before it is indexed.

          So I may need to create a special index, not sure. Will need to read further.
          Poddys Rambles On

          Comment


          • #6
            Re: SQL Full Text Search on AS400 Database

            It seems that Omnifind has now been replaced by a new Enterprise product, however from V6.1 onwards it should be possible to achieve this using Text Extenders - I think...

            This document appears to be a bit clearer to understand and more comprehensive:


            Still trying to digest everything at this point and have not been able to try anything. We are just interested in being able to search a column in an AS400 file that contains all the keywords for a product, but the Text Extenders should allow you to index and search documents and files on the IFS, which might be really handy to know.
            Poddys Rambles On

            Comment

            Working...
            X