SAP TRex and Enterprise Search tips

TRex is one of the most complicated solution of SAP.  This is the memo for configuring and troubleshooting TRex.

# Enterprise Search
Enterprise Search is not equal to TRex at this time. Though I forgot where I got the following picture, it is very good overview.
![10.EnterpriseSearchOverview.png](https://qiita-image-store.s3.amazonaws.com/0/134273/41367896-324d-fd49-c1cd-0f4cbd0668f3.png)
Many Search UI/UXs use Enterprise Search with various ways. At first, search function is only implemented on TRex.  After releasing SAP HANA, SAP is shifting the function from TRex to SAP HANA.

# Search Mode
## Linguistic Search
All grammatical forms of the search term will be listed on the result page (i.e. plural, singular and flexion). For example if you enter mice, the system also looks for mouse.

##Fuzzy Search
This search method is error-tolerant and also includes similar search terms. You can search for words or phrases that are spelled like the search phrase, according to an
           adjustable editing-distance similarity criterion. You get results even for misspelled queries, the fuzziness is adjustable.
           For example, if you enter president, the system also finds documents that contain presidant.

##Exact Search
With this method, you find only documents that contain exactly the search term or phrase that you entered. You can also use placeholders with this search method 

##Exclude Phrase
This search method excludes complete phrases, which you don’t want to be listed on the result page.

# Useful tools
## ABAP Task list(T-cd:stc01)
When configuring Enterprise Search, the ABAP task list is very useful. Be careful it contained many errors.

## TRex Administration tool(T-cd:trexadmin)
Seeing technical information on TRex.  Python trace can be activated via this tool.

## ESH Modler(T-cd:esh_modeler)
Seeing and configuring search models. When enhancing search models, use this tool. Search Models and search object connector are very complicated.  Check the [help doc](https://help.sap.com/saphelp_nwes73/helpdata/en/4a/654f87cd241c50e10000000a42189c/frameset.htm) for understanding.

## ESH Cockpit(T-cd:esh_cockpit)
Managing search object connectors. Creating indexes via this tool.

## Enterprise Search Logging(T-cd:esh_ql_cust & esh_query_log)
Trace Enterprise Search log.

## NLP relevant function
see [note 1590617 - How to enable semantic/synonym search (topic maps) - TREX 7.1](https://launchpad.support.sap.com/#/notes/0001590617).  Semantic / synonym search is one of the most essential feature of the NLP(Natural Language Processing).

# Language Recognition and Processing Function
[Link](https://help.sap.com/saphelp_nw70/helpdata/en/21/f23841d9338739e10000000a1550b0/frameset.htm) shows how to process language recognition and post-process.
![Language Recognition and Processing Function](https://help.sap.com/saphelp_nw70/helpdata/en/46/c5e0b666670e5ce10000000a1553f7/TEMPLATE_image002.gif)

# Language relevant configuration
## Configure Language on TRex
See help ["Configuring Language Recognition"](https://help.sap.com/viewer/dab593a777a843adafb694d62f087b17/106/en-US/141c063c66171b3de10000000a11402f.html)

## Change Default Language from English(For only Enterprise Search)
**Be careful!! This configuration is not recommended by note 1770500.  ** 
Run report "ESH_IDX_SET_DEFAULT_LANGUAGE" via t-cd:sa38/se38.  See note [1770500 - Customizing report for changing default language f. indexes](https://launchpad.support.sap.com/#/notes/0001770500) for further detail.
## For Japanese configuration
Check if [note 1666973 - TREX 700/710 : search in language japanese doesn't work as expected](https://launchpad.support.sap.com/#/notes/0001770500) and [976213 - TREX 6.1/7.0/7.1: Options for Japanese language] (https://launchpad.support.sap.com/#/notes/976213/E) have been applied. The attached file to the note is as follows.

```
<?xml encoding="UTF-8" ?> 
<!-- $RCSfile: analysis-language-config,v $ $Revision: 1.1 $ $Date: 2001/08/15 00:44:56 $ -->
<!--TREX: analyze=expanded-->
<!--TREX: normalizeWidth=1-->
<!--TREX: sufficientKana=5-->
<!--TREX: normalizeStem=kana-->
<!--TREX: decompose=off -->
<sentence-ending-punct>
	<item key = "." />
	<item key = "?" />
	<item key = "!" />
	<item key = "。" />
	<item key = "？" />
	<item key = "！" />
	<item key = "：" />
</sentence-ending-punct>
<start-bibliography-section>
        <item key = "謝辞" />
	<item key = "付録" />
	<item key = "参考文献" />
	<item key = "引用文献" />
	<item key = "文献" />
	<item key = "引用" />
	<item key = "索引" />
	<item key = "備考" />
	<item key = "その他" />
	<item key = "注" />
	<item key = "注）" />
	<item key = "脚注" />
	<item key = "付記" />
</start-bibliography-section>
<end-bibliography-section>
        <item key = "**********" />
</end-bibliography-section>
<sentence-starts>
        <item key = "&quot;" />
</sentence-starts>
<uncapitalized-title-words>
	<item key = "not" />
        <item key = "n't" />
        <item key = "the" />
	<item key = "an" />
        <item key = "a" />
        <item key = "and" />
	<item key = "and/or" />
        <item key = "as" />
        <item key = "but" />
	<item key = "if" />
        <item key = "nor" />
        <item key = "or" />
	<item key = "till" />
        <item key = "about" />
        <item key = "after" />
	<item key = "as" />
        <item key = "at" />
        <item key = "before" />
	<item key = "but" />
        <item key = "by" />
        <item key = "down" />
	<item key = "ere" />
        <item key = "for" />
        <item key = "from" />
	<item key = "into" />
        <item key = "in" />
        <item key = "of" />
	<item key = "onto" />
        <item key = "on" />
        <item key = "out" />
	<item key = "per" />
        <item key = "to" />
        <item key = "under" />
	<item key = "until" />
        <item key = "unto" />
        <item key = "upon" />
	<item key = "up" />
        <item key = "with" />
</uncapitalized-title-words>
<non-sentence-ending-abbrev>
          <item key = "e.g." />
          <item key = "i.e." />
          <item key = "viz." />
          <item key = "a.k.a." />
<!-- All titles are assumed not to break sentences
     Not included in this list are: Esq., Jr., Sr.
     Ret., Retd. -->
          <item key = "Adm." />
          <item key = "Br." />
          <item key = "Capt." />
          <item key = "Cdr." />
          <item key = "Cmdr." />
          <item key = "Col." />
          <item key = "Comdr." />
          <item key = "Comdt." />
          <item key = "Dr." />
          <item key = "Drs." />
          <item key = "Fr." />
          <item key = "Gen." />
          <item key = "Gov." />
          <item key = "Hon." />
          <item key = "Ins." />
          <item key = "Lieut." />
          <item key = "Lt." />
          <item key = "Maj." />
          <item key = "Messrs." />
          <item key = "Mdm." />
          <item key = "Mlle." />
          <item key = "Mlles." />
          <item key = "Mme." />
          <item key = "Mmes." />
          <item key = "Mr." />
          <item key = "Mrs." />
          <item key = "Ms." />
          <item key = "Pres." />
          <item key = "Prof." />
          <item key = "Profs." />
          <item key = "Pvt." />
          <item key = "Rep." />
          <item key = "Rev." />
          <item key = "Revd." />
          <item key = "Secy." />
          <item key = "Sen." />
          <item key = "Sgt." />
          <item key = "Sra." />
          <item key = "Srta." />
          <item key = "St." />
          <item key = "Ste." />
</non-sentence-ending-abbrev>

```
# Enhancement
## Checking MIME information during extraction
~~Enhancement spot BADI_ESH_IF_BINARY_MIME_TYPE is for MIME management during extraction.  For example, BAdi definition BADI_ESH_IF_CHECK_FILE_SIZE filters via size or size and MIME type.  100MB is the max size by default.  For further detail, see [1739836 - Problems with text (files) in Enterprise Search](https://launchpad.support.sap.com/#/notes/1739836).~~
This is an old information. [Note 1739836 - Problems with text (files) in Enterprise Search](https://launchpad.support.sap.com/#/notes/1739836) explains how to filter files.

# Trouble shooting
## How to trace trex 
-> [Recording a Python Trace in Transaction TREXADMIN](https://wiki.scn.sap.com/wiki/display/BI/Recording+a+Python+Trace+in+Transaction+TREXADMIN)