Skip to content

Instantly share code, notes, and snippets.

Created September 7, 2011 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1201204 to your computer and use it in GitHub Desktop.
Save anonymous/1201204 to your computer and use it in GitHub Desktop.
ES vs SOLR faceting
// Index Creation
$index->create(array(
'index' => array(
'number_of_shards' => 1,
'number_of_replicas' => 0,
'_source'=>array("enabled"=>false),
"analysis" => array(
"analyzer" => array(
"index_analyzer" => array(
"tokenizer" => "standard",
"filter" => array("standard", "my_delimiter", "lowercase", "asciifolding")
),
"search_analyzer" => array(
"tokenizer" => "standard",
"filter" => array("standard", "my_delimiter", "lowercase", "asciifolding")
),
),
"filter" => array(
"my_delimiter" => array(
"type" => "word_delimiter",
"generate_word_parts" => true,
"catenate_words" => false,
"catenate_numbers" => false,
"catenate_all" => false,
"split_on_case_change" => false,
"preserve_original" => true,
"split_on_numerics" => false,
"stem_english_possessive" => false
),
),
)
)
), true);
// Mapping
$properties = array(
'facets_author' => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
'facets_subject' => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_date" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_bibtype" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_biblevel" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_biblevel_full" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_class" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_class_desc" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_subject" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"facets_place" => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed', "include_in_all" => false),
"turbo_marc" => array('type' => 'string', 'store' => 'yes', 'index' => 'no', "include_in_all" => false),
);
$templates = array(array(
"template_mrc" => array(
"match" => "mrc_*",
"mapping" => array(
"type" => "string",
"store" => "no",
"include_in_all" => false,
"index" => "analyzed",
"index_analyzer" => "index_analyzer",
"search_analyzer" => "search_analyzer",
),
),
),
array(
"template_sf" => array(
"match" => "sf_*",
"mapping" => array(
"type" => "string",
"store" => "no",
"include_in_all" => false,
"index" => "analyzed",
"index_analyzer" => "index_analyzer",
"search_analyzer" => "search_analyzer",
),
),
),
);
$mapping->setParam("properties", $properties);
$mapping->setParam("dynamic_templates", $templates);
$mapping->setParam("_source",array("enabled"=>false));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment