image16.gif

 


 

 

Solr

 

Please contact support if you would like to have SOLR enabled for your installation. The SOLR search feature may be enabled per interface (website) or per website project. If you’d like to experiment with it, please create a new project from live in your Website Template Manager and then let us know the name of the project. You will be able to use the SOLR features while in preview mode for this project.

 

For details on SOLR tokenizers and filters, please see the full SOLR documentation.

 

Cores

Solr databases are called cores. By default, you’ll have a product core that contains searchable product information. This usually includes fields like product id, part number, name, and description, but can include whatever product data you like. You may also have an optional category core that contains searchable category information. Please note that the category core is not used by the standard web site search feature. If utilized, it must be customized per client.

 

AJAX Target

 

Once SOLR is enabled, you will have access to a new AJAX target /ajax_targets/solr.php. This AJAX endpoint will perform one or more search-related commands. To perform a particular command, include the command name in a colon-separated list via the query parameter. For example, issue the following to perform the search and popular commands on the term “foo”:

query=search:popular&term=foo

 

The results will be a JSON encoded array, indexed by the name of the command:

{     
     "search": [ <search results> ],
     "popular": [ <popular results> ]
}
 

If no query parameter is specified, a search command will be run, with a subsequent spellcheck if the search returns no results.The available commands are:

 

automcomplete

 

A search on matching string prefixes. For example, a search for “sola” might return a list of terms like “solar”, “solarium”, “solar-powered.” This is generally used to autocomplete search terms in a search form and is typically populated from the product name field, but is not restricted to it. The database tables fulltext_search_autocomplete and fulltext_search_autocomplete_fields determine which fields are used to seed this data.

 

Parameters:

 

Name Required Value Description
term   yes string The term to search.
name no string The name of the autocomplete to use. These are defined in the fulltext_search_autocomplete name field. If not specified, it will default to autocomplete_phrase.

 

 

Example:

/ajax_targets/solr.php?query=autocomplete&name=my_custom_autocompleter&term=foo

 

Result:

{

     "autocomplete": [

         "food",

         "fool",

         "foot"     ]

 }

 

 

popular

 

A search for the most popular search terms. These are tracked in the fulltext_search_popular table. No parameters are required, this will simply return the top ten search terms for the interface.

 

Example:

/ajax_targets/solr.php?query=popular

 

Result:

 

{     "popular": [

         "kittens",

         "explosions",

         "bears"     ]

 }

 

spellcheck

A search to determine possible corrections of an incorrectly spelled word. This is often used when a search result returns zero matches.

 

Parameters:

Name Required Value Description
term   yes string The term to search.

 

Example:

/ajax_targets/solr.php?query=spellcheck&term=kitton

 

Result:

{     

"spellcheck": [

         "kitten",

         "kittens",

         "kitting",

         "button",

         "cotton"     ]

 }

 

synonyms

A search to determine locally defined synonyms for words. For example, “green” might be defined as synonymous with “eco-friendly.” These are defined in the database table fulltext_search_synonyms. Note that the search command already takes these synonyms into account, so this command acts merely as a convenience feature in the case where an explicit display list is desired.

 

Parameters:

Name Required Value Description
term   yes string The term to search.

 

Example:

/ajax_targets/solr.php?query=synonym&term=green

 

Result:

{     

"synonyms": [

         "eco-friendly",

         "environmentally friendly"     ]

 }

 

search

 

A full-text search of product information. E.g., search for “shoe” to find the product ids of all shoes. The fields searched are determined via the fulltext_search_config table. Note that each interface may have its own set of fields to be searched, and certain products may only be available on certain interfaces.

 

Enhanced Solr search to perform the following:

1. Support requesting Solr search result relevance in detail field list. This field is always allowed, regardless of the listed allowable fields.

2. Previously, you could select detail only if there were less than 11 search results. Now, if there are more than 12, you'll get detail, but only for the first 12.

 

Parameters:

 

Name Required Value Description
term   yes string The term to search.
core    no string The core to search in, currently one of "product" or "category". If no specified, defaults to the product core.
limit   no integer Limit the results set to this many items. If not specified, defaults to 1000.
detail   no boolean Include the full product detail, not just the product ID. This parameter will only be honored if the results set is less than or equal to12 items.
fields   no string If detail is specified, this parameter may contain a comma separated list of fields to include in the result. This list must be a subset of the fields specified via the Available Solr AJAX Category Fields and Available Solr AJAX Product Fields settings in the channel_system_settings table. If detail is requested but no fields are specified, all the fields listed in the channel_system_settings table will be returned.

 

 

Example:

/ajax_targets/solr.php?query=search&term=foo

 

Result:

{

     "search": [

         37,

         42,

         138     ]

 }

 

 

Example:

/ajax_targets/solr.php?query=search&term=foo&limit=2&detail=1

 

Result:

 

{

     "search": [

         {

             "id": "37",

             "name": "foo",

             "base_price": "19.95",

             "part_num": "abc123"

             ...

         },

         {

             "id": "42",

             "name": "bar",

             "base_price": "9.95",

             "part_num": "789xyz"

             ...

         }

     ]

 }

 

System Settings

 

There are a number of system settings that affect Solr in various ways:

 

Channel System Settings

 

Name Value Description
Available Solr AJAX Product Fields string

A comma-separated list of product fields that will be returned by the AJAX search feature when detail is requested but no product fields are listed.

Available Solr AJAX Category Fields string

A comma-separated list of product fields that will be returned by the AJAX search feature when detail is requested but no category fields are listed.

 

 

Global System Settings

 

Name Value Description

Solr Dictionary Indexer

string

The type of indexer to use for creating the Solr spellcheck dictionary. If not specified, defaults to FileBasedSpellChecker. Can also be set to IndexBasedSpellChecker. Please note that spellcheck dictionaries are only created in the product core.

Solr Dictionary Source

 

string

The source of data for the Solr spellcheck dictionary. If FileBasedSpellChecker is used, this indicates the name of a text file to obtain words from. If IndexBasedSpellChecker is used, this indicates the name of the Solr field to obtain words from. If not specified, defaults to the built-in English dictionary file named dictionary.txt .

 

 

 

Database Tables

 

The following database tables can be edited via the Technical Configuration Manager to customize the behavior of the SOLR search feature.

 

fulltext_search_synonyms

 

Defines synonyms for search terms. Once defined here, these are used automatically by the search command, there is no further configuration required. Please note that if you create “foo” as a synonym for “bar” then you do not also need to create “bar” as a synonym for “foo”.

 

Field Type Description

id

integer

Primary key.

term

string

The term that has a synonym.

synonym

string

The synonym for the term.

 

 

fulltext_search_popular

 

Contains a history of what website visitors are searching for. This is used to feed the popular command.

 

Field Type Description

id

integer

Primary key.

interface_id

integer

The interface (website) id that this search was performed on.

terms

string

The search term(s) that were used.

popularity

integer

The number of times this search term returned results. A negative value indicates the number of times this search term returned no results, so sort this table by popularity descending to find the most popular searches.

 

 

fulltext_search_autocomplete

 

Each row defines an autocompleter that can be searched via the autocompleter command.

 

Field Type Description

id

integer

Primary key.

name

string

The name of the autocompleter, to be passed via the name parameter for the autocomplete command.

type

string

The SOLR tokenizer to use for the input fields. One of autocomplete_word or autocomplete_phrase.

count

integer

The default number of results to return if not specified via the limit parameter.

interface_id

integer

The interface (website) id that this field applies to.

 

 

fulltext_search_autocomplete_fields

 

Indicates which fields are indexed for a particular autocompleter.

 

Field Type Description

id

integer

Primary key.

autocomplete_id

integer

The fulltext_search_autocomplete.id value from the associated autocompleter.

info_field_id

integer

The info_fields.id value from the associated info field.

 

 

fulltext_search_config

 

Indicates which fields will be indexed for which interfaces (websites).

 

Field Type Description

id

integer

Primary key.

interface_id

integer

The interface (website) id that this field applies to.

assoc_entity

string

One of Product or Category.

info_field_id

integer

The info_fields.id value from the associated info field.

 

 

fulltext_search_config_solr

 

Contains SOLR-specific configuration overrides for an indexed field.

 

Field Type Description

id

integer

Primary key.

info_field_id

integer

The info_fields.id value from the associated info field.

type

text

The SOLR tokenizer to use for the field.

indexed

enum(true,false)

If true, the field will be indexed and searchable.

stored

enum(true,false)

If true, the field will be returned in the result record of searches. Note it doesn’t make much sense to have both indexed and stored set to false.

boost

float

The SOLR boost value to apply to this field. Values are relative and mean nothing inherently, so it is meaningless to give all fields the same boost. Fields without an explicit boost have a value of 1.

 

 

interfaces

 

Defines the distinct websites your installation supports. Within this table is a field default_root_category_id which defines the default root category id for the associated site.

 

Field Type Description

default_root_category_id

integer

The category ID considered the “base” category for this interface.

 

 

 

 

 

 

 

 

 

 

 

 

 

© 2015 CORESense · 1-866-229-2804 · info@coresense.com · 125 High Rock Avenue, Saratoga Springs, NY 12866