How can I use TREX?

Hi experts!
We want to use TREX as our search engine.
The following link already show some results for our system:
[http://trexsourcesearch.wdf.sap.corp:31305/webkit/TREX/abapsearch/search.psp|http://trexsourcesearch.wdf.sap.corp:31305/webkit/TREX/abapsearch/search.psp] and also the RFC-connection check in SM59 for TREX_SOURCE_SE is ok. So it seems that TREX is already running and configured on our system.
Our aim is to write a simple (test)report where you can enter e.g. a string. TREX searchs (maybe) our whole component for this string. TREX returns the search results and our report shows all the results.
So my question is:
How can I do this? Which function modules/methods... should I call to solve this problem?
I've found the following link but I think it describes only how TREX works and how it is to administer.
[http://help.sap.com/saphelp_nw70/helpdata/EN/46/cbe4bb63a668dfe10000000a114a6b/frameset.htm|http://help.sap.com/saphelp_nw70/helpdata/EN/46/cbe4bb63a668dfe10000000a114a6b/frameset.htm]
Thanks and regards,
Christian
Edited by: Christian Honeder on Sep 8, 2008 12:58 PM

I've founde a solution:
Useful is the transaction "TREXADMIN". Here you can see if your index has been created and if you have feed it correctly. You can also search for the attributes which you have added to the index.
But this transaction requires a special permission. Therefore you can use the search-methods in CL_COM_SE_TREX instead. The mentioned class provides a lot of functions for TREX
The following example shows how to create and feed the TREX index with one document. The search attributes itself are contained in lt_doc_attr. In this internal table you will have the fieldname (later displayed in TREXADMIN) and the value (you can search for this).
Comment: After you've feed the index you might have to wait some time until the fields in TREXADMIN appear or the search routines find something.
Create the TREX index:
* Get trex instance
  lr_trex = cl_com_se_trex=>if_com_se_trex~get_instance( ).
  CHECK lr_trex IS BOUND.
* Prepare Index Attributes
  l_trex_id = 'your_trex_id'.                         "unique
  l_rfc_destination = 'your_rfc_destination.
  CALL FUNCTION 'CONVERSION_EXIT_ISOLA_OUTPUT'
    EXPORTING
      input  = sy-langu
    IMPORTING
      output = l_langu.
* Create index
  CALL METHOD lr_trex->create_index
    EXPORTING
      iv_index_id        = l_trex_id
      iv_rfc_destination = l_rfc_destination
      iv_language        = l_langu
    IMPORTING
      ev_return_code     = l_rc
    EXCEPTIONS
      conversion_error   = 1
      error              = 2
      OTHERS             = 3.
Feed the TREX index:
The table lt_doc_attr has been filled in a subroutine.
DATA ls_doc_list            TYPE trexs_index_doc.
DATA lt_doc_list            TYPE trext_index_docs.
DATA lt_doc_attr            TYPE trext_indexdoc_attrs.
*   Feed Index
    l_doc_key = ls_doc_key-doknr.      "unique
    ls_doc_list-doc_key     = l_doc_key.
    ls_doc_list-doc_langu   = l_langu.
    ls_doc_list-class_rel   = 1.
    ls_doc_list-doc_type    = 'A'.    "text ASCII
    ls_doc_list-doc_action  = 'I'.    "index, alternative: D(index)
* some values for ls_doc_list-doc_type
*     A  text (ASCII); standard is A
*     F  file
*     U  url
*     B  binary
*   Copy search attributes into the structure
    ls_doc_list-doc_attr  = lt_doc_attr.
    APPEND ls_doc_list TO lt_doc_list.
*   Now feed the index with the new document
    CALL METHOD lr_trex->feed_index
      EXPORTING
        iv_index_id            = l_trex_id
        iv_rfc_destination     = l_rfc_destination
*        iv_use_queueserver     = 'X'
        it_index_document_list = lt_doc_list
*        iv_flush_after_index   = 'X'
      IMPORTING
        ev_return_code         = l_rc
      EXCEPTIONS
        conversion_error       = 1
        error                  = 2
        OTHERS                 = 3.
Delete the TREX index:
* Delete the Index
  CHECK del_idx = abap_true.
  CALL METHOD lr_trex->delete_index
    EXPORTING
      iv_index_id        = l_trex_id
      iv_rfc_destination = l_rfc_destination
    EXCEPTIONS
      conversion_error   = 1
      error              = 2
      OTHERS             = 3.
How to search in the TREX index
You can use the trex instance instead of the function module to search the index.
*  Search for a special fieldvalue
    ls_query_entry-location = 'FIELDNAME'.   "a fieldname which you have added with lt_doc_attr
    ls_query_entry-value1 = l_txt.           "maybe a text from the selection screen
    ls_query_entry-rowtype = 'ATTRIBUTE'.
    ls_query_entry-operator = 'EQ'.
    APPEND ls_query_entry TO lt_query_entry.
*  Search for a string
*  Add the operator only if you've added a fieldname
    ls_query_entry-value1 = 'AND'.
    ls_query_entry-rowtype = 'OPERATOR'.
    ls_query_entry-operator = 'EQ'.
    APPEND ls_query_entry TO lt_query_entry.
    ls_query_entry-value1 = l_string.
    ls_query_entry-rowtype = 'TERM'.
    ls_query_entry-operator = 'EQ'.
    APPEND ls_query_entry TO lt_query_entry.
* All attributes are requested
  ls_requ_attributes-attr_name = '*'.
  APPEND ls_requ_attributes TO lt_requ_attributes.
* 1: DidYouMean, 2: Snippets 4: TitleSnippets or a bit combinaton
  l_request_flag = 2.
* Search the index
  CALL FUNCTION 'TREX_EXT_SEARCH_DOCUMENTS'
    EXPORTING
      i_indexes                           = lt_index        "table with your index id
      i_rfc_destination                   = l_rfc_destination
      i_result_from                       = l_res_from    "how many results should be found?
      i_result_to                         = l_res_to
      i_max_snippet_words                 = 30
      i_request_flags                     = l_request_flag
      i_query_entries                     = lt_query_entry
      i_req_attributes                    = lt_requ_attributes
    IMPORTING
      e_result_docs                       = lt_result_doc.
      e_no_of_hits                        = l_no_of_hits
      e_no_of_all_hits                    = l_no_of_all_hits
      e_index_size                        = l_index_size.

Similar Messages

  • How can I measure TREX server.

    Hi,
    I'm from Nakisa forum as below.
    <How can I calc sizing of TREX server
    I'd like to install minimum TREX server for Nakisa.
    A document of nakisa is written about nakisa server but it isn't written trex server.
    <https://websmp209.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000728933&_SCENARIO=01100035870000000202&>
    I found SAP note 1266024 which is written about sizing guide line of Nakisa but it's so difficult to calc.
    How can I measure TREX server and which minimun sizing is best to use Nakisa?
    Hope you can help us.
    Best regards,
    Makoto

    Hi Makoto,
    try the infos for TREX under http://service.sap.com/sizing.
    They are not made for Nakisa. But I am sure you will be able to roughly map them to your use case.
    best, Karsten

  • How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes?

    How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes? I wanted my teenager's AppleID to be different from mine so that she couldn't charge stuff to my AppleID, therefore I created me another one. Now when I go to Sync either device, it tells me that this IOS device can only be synced with one AppleID. Then I get a message to erase it, not going to do that, lol. If I logout as one ID and login as the other, will it still retain all synced information on the PC from the first IOS device? If I can just log in out of the AppleID, then I have no problem doing that as long as the synced apps, music, etc stays there for both. I am not trying to copy from one to the other, just want to make sure I have a backup for the UhOh times. If logging in and out on the same PC of multiple AppleIDs is acceptible then I need to be able to authorize the PC for both devices. Thanks for the help. I am new to the iOS world.

    "Method Three
    Create a separate iTunes library for each device. Note:It is important that you make a new iTunes Library file. Do not justmake a copy of your existing iTunes Library file. If iTunes is open,quit it.
    This one may work. I searched and searched on the website for something like this, I guess I just didn't search correctly, lol. I will give this a try later. My daughter is not be back for a few weekends, therefore I will have to try the Method 3 when she comes back for the weekend again. "
    I forgot to mention that she has a PC at her house that she also syncs to. Would this cause a problem. I am already getting that pop up saying that the iPod is synced to another library (even though she is signed in with her Apple ID to iTunes) and gives the pop up to Cancel, Erase & Sync, or Transfer Purchases. My question arose because she clicked on "Erase & Sync" by mistake when she plugged the iPod to her PC the first time. When the iPod was purchased and setup, it was synced to my PC first. When she went home, she hooked it up to her PC and then she erased it by accident. I was able to restore all the missing stuff yesterday using my PC. However, even after doing that it still told me the next time I hooked it up last night that the iPod was currently synced with a different library. Hopefully, you can help me understand all this. She wants to sync her iPod and also backup her iPod at both places. Both PCs have been authorised. Thanks

  • How can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    how can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    If you are just visiting Singapore, then leave the account as it is. If you have moved there, then view your account using the iTunes app on a Mac or PC and change the country/region to your current location and address. If you do not have a bank card, you can fund your account using iTunes gift cards if available in Singapore.

  • How can I use one photo twice in a slideshow

    I am in iPhoto '11 9.4.3 making a slideshow to send to iDVD for my mother-in-laws funeral next Wednesday.
    How can I use this one particular photo of her several times in the slide show.
    I have tried copy/past and that does not seem to work.
    Thanx in advance

    I would just duplicate the picture several times and keep inserting duplicates ...

  • How can i use microsoft word on ipad 2

    how can i use the microsoft application on my ipad 2?

    The Pages app is also compatible with MS Word. Unlike some of the others mentioned, the document is actually stored on the iPad as opposed to 'the clouds'. Again, most of those mentioned are cut down versions of MS Word.
    Stand back and look at this constructively; do you need to regularly access to the document from more than one computer/device without the need to keep amending your document on your computer and sending it to your iPad? If so, Documente to Go etc may be the best choice.

  • How can I use the credit on my account instead of credit card to buy apps?

    I have a gift card credit on my account but when I want to buy an app it takes me to my credit card details. How can I use my credit on my account instead of credit card?

    You shouldn't have to put in a credit card, no, but from time to time the iTunes Store seems for some reason to try to insist on one. If just confirming your mailing address doesn't stop it from complaining, go here:
    http://www.apple.com/support/itunes/contact/
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • How can i use one SQL statement to solve problem?

    How can i use one SQL statement to solve the question below?
    For a Table named A, there is a column named F(char type).
    Now select all the records where F like '%00' and update their F value to '%01'
    Just one SQL statement.Do not use PL/SQL block.
    How to do that?
    Thanks.

    What is the data volume for this table?
    Do you expect lots of rows to have '%00' as their value?
    Following two statements come to mind. Other experts would be able to provide better alternatives:
    If you have index on SUBSTR(f, 2):
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) || '01'
    WHERE  substr(f,
                  -2) = '00';If most of the rows have pattern '%00':
    UPDATE A
    SET    f = SUBSTR(f,
                      1,
                      length(f) - 2) ||
               DECODE(SUBSTR(f,
                             -2),
                      '00',
                      '01',
                      SUBSTR(f,
                             -2));

  • How can i use one iCloud Photostream on 2 devices?

    Due to a bug (or feature) on iOS 8 i can't use the same icloud id on 2 iphones:
    https://discussions.apple.com/thread/6536998
    So how can i use ONE iCloud Photostream then on 2 devices?
    Also, on OSX i can define only one Photostream.
    So, how do you import pictures from 2 streams into iPhoto?
    Familyshare is not usefull as the pictures are not in Original-Filesize!

    Hi ..
    Yes. " iPhone 6 or 6 Plus.  iPad Air 2  or  iPad mini 3"
    Set up and use Apple Pay

  • HT204053 Dear Support Team, every time i tried to logon Icloud its gives me wrong user name or password and at the end it show me error " This Apple ID is valid but is not an ICloud Account" then how can i use one account for same Apple ID and ICloud???

    Dear Support Team,
    Every time i tried to logon Icloud its gives me wrong user name or password and at the end it show me error " This Apple ID is valid but is not an ICloud Account" then how can i use one account for same Apple ID and ICloud?
    Thanks

    It is not possible to create a new iCloud account using a Windows machine. You must create the account using a Mac (10.7.5 or more) or an IOS device (iPhone etc). Once that is done you can sign into and use the account on your Windows machine.

  • How can I use same account in 2 iphone with diff contact list?

    how can I use same account number but other all totally diff such as contact list, application, everything ..... I found that it's bad on IOS5.
    when I used IOS4 .. old verison, I can keep my phone in diff data. Afte upgrade IOS 5, it's bad. Even take photo, it can not focus zoom in and out.

    how can I use same account number but other all totally diff such as contact list, application, everything ..... I found that it's bad on IOS5.
    when I used IOS4 .. old verison, I can keep my phone in diff data. Afte upgrade IOS 5, it's bad. Even take photo, it can not focus zoom in and out.

  • How can i use my ipod on 2 computers without deleting my music

    how can i use my ipod on 2 computers without deleting my music on ipod?

    See here: Using iPhone, iPad, or iPod with multiple computers
    B-rock

  • How can I use home sharing between our iphones (create playlists from both accounts at once)

    How can I use home sharing between our iphones, so that we can create playlists with songs from both of our libraries?  We share a Macbook Pro (separate accounts) and each have the new iphone, but when I have my iphone and try to create a new playlist, I can only grab songs from one account.  Is there a way to create a playlist using both accounts since we are sharing?
    Does it have to be created within iTunes first on our Mac?

    The short answer: because Home Sharing isn't designed for sharing apps, and apps aren't designed to be shared.
    The longer answer:  Think of it like this...
    You download some music in iTunes.  With Home Sharing, another user can listen to it by streaming it over the network.  But the data itself is on your computer.  If you turn off the computer or take it off the network, the other user can't access it.
    But if you send another user the app, they aren't just streaming the data- they installed it on their iOS device.  Because they weren't the one that purchased it, such a transfer could easily be considered "piracy" or "stealing," and nobody likes that (least of all, Apple). 
    When iTunes sees this app, it obviously recognized it, as if saying, "Hey, how did you get this app on your device, if I have no record of you purchasing/downloading it from the iTunes store?"
    post edited to correct spelling errors

  • How can I use the old Apple TV with new iTunes?  It tells me to input a code in iTunes but iTunes no longer has a spot to input this code to allow sync.  I can access the iTunes Store fine, just none of my Library

    How can I use the old Apple TV with new iTunes?  It tells me to input a code in iTunes but iTunes no longer has a spot to input this code to allow sync.  I can access the iTunes Store fine, just none of my Library

    read this
    https://discussions.apple.com/message/20429789#20429789

  • HT204053 i RECENTLY PURCHASED ANOTHER IPHONE.  MY INTERNET IS NOT WORKING.  I JUST CREATED AN APPLE ID.  WHAT'S NEXT?  I NOW HAVE TWO DIFFERENT ACCOUNTS WITH DIFFERENT USER NAMES.  HOW CAN I USE ONLY ONE ACCOUNT FOR ITUNES, ICLOUD APPLE ID ETC???

    I RECENTLY PURCHASED ANOTHER IPHONE.  MY INTERNET IS NOT WORKING.  I JUST CREATED AN APPLE ID.  WHAT'S NEXT?  I NOW HAVE TWO DIFFERENT ACCOUNTS WITH DIFFERENT USER NAMES.  HOW CAN I USE ONLY ONE ACCOUNT FOR ITUNES, ICLOUD APPLE ID ETC???

    Welcome to the Apple community.
    iTunes and iCloud and different accounts, you will need to delete both accounts from your device before adding the new details in their place.
    For iCloud go to settings > iCloud, scroll down and hit the delete button. You can then sign back in using your correct details. For iTunes go to settings >store, tap your account ID and then sign out, you can then sign back in using your correct Apple ID.

Maybe you are looking for

  • Java 7 Web start fails to download Java 1.6 version

    Sorry for the almost exact duplication of a previous thread, but that was closed (Java 7 Web start fails to download Java 1.6 version When launching an application requiring Java 1.6 with a Java 1.7 web start it fails when it tries to download 1.6 wi

  • How to divide 2 columns totals in ALv grid

    Hi All, i developed alv report & displayed totals. now i need to divide those totals and display as another column total. anyone please suggest. col1    col2    col3 tot1     tot2     tot3 tot3 = tot2 / tot1. thanks,

  • Why is my server trying to connect to the printers on my local network?

    I have a remotely hosted Windows Server 2012 web server which I connect to via RDP.  The weird thing is, in the event log for my server, I'm always seeing these same four errors.  Each one of them pertains to one of the printer drivers I have install

  • ResourceException: Access not allowed (when trying to grab a connection from weblogic pool)

    I am using WLS7 with SP1. I just recently migrated from WLS6.0. When my code tries to grab a connection from the pool, it throws an exception java.sql.SQLException: Pool connect failed: weblogic.common.ResourceException: Access not allowed at weblogi

  • Servers on HANA

    Hi, When i went through the documentation, to know the status of the HANA, we need to make sure that index server, name server, preprocessor servers are up and running. A few queries on this: 1. where do we can see in HANA studio about the details of