Add fields to searchable fields


https://forum.kartris.com/Topic668.aspx
Print Topic | Close Window

By saturation - Tue 28 Jun 2011
Where can I find which fields are searchable from the searchbox?   How can I add another field to that searchable fields?
By Mohammad - Wed 29 Jun 2011
That is exist in the search stored procedure your website is using, which could be either "spKartrisDB_Search" (default) or "spKartrisDB_SearchFTS" (if you enabled Full Text Search in your database).

By default Kartris searches in the following fields:

1. Version's Name & Description (if you have less than 10,000 versions)
2. Version's Code Number (always)
3. Product's Name & Description (always)
4. Product's Attribute Values (if they are searchable)

Adding new fields to be searchable is a bit tricky and a bit difficult to apply for the 1st time.

In the search stored procedure, line 44 or 42 - depending on how many versions you have:
SET @DataToSearch = '(LE_TypeID IN (1,2,14) AND LE_FieldID IN (1,2))'

1. You need to know the table ID you want, check table 'tblKartrisLanguageElementTypes'
2. You need to know the field ID you want, check table 'tblKartrisLanguageElementFieldNames'
3. There should be a connection (link) between the table and the field, check table 'tblKartrisLanguageElementTypeFields'
4. a) If the needed table and field are exist in the above 2 tables, then just add them to line 44 or 42 in the correct places, near the corresponding IDs, for example if the table id is 'x' and field id is 'y' then the above code could become:
SET @DataToSearch = '(LE_TypeID IN (1,2,14,x) AND LE_FieldID IN (1,2,y))'

   b) If the needed table and field are not exist in the above tables, then you need to study the search stored procedure and add your (dynamic) SQL it in the correct place, if you had any problems or difficulties, just let me know which table/field you want to add and will give you hands on this.
By saturation - Fri 1 Jul 2011
Thank you!   That worked perfect!
By saturation - Fri 1 Jul 2011
Ok, one more thing.   I then tried adding the category name (table 3, field 1), so now my search variables look like

    IF @NoOfVersions > 10000 BEGIN
        SET @DataToSearch = '(LE_TypeID IN (2,14,3) AND LE_FieldID IN (1,2,7))'
    END ELSE BEGIN
        SET @DataToSearch = '(LE_TypeID IN (1,2,3,14) AND LE_FieldID IN (1,2,7))'
    END

The search results count is correct, but it returns nothing because there are no products or versions specifically with the category name in it.   Is there any way to get all products and/or versions returned if someone types in a category name?
By Mohammad - Fri 1 Jul 2011
In this case, you need to write your own code to handle that, the existing search doesn't return the products/versions under a searched category, simply because the categories could be easily navigated.