Skip to content

Instantly share code, notes, and snippets.

@mauricioalarcon
Created October 27, 2011 13:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mauricioalarcon/1319548 to your computer and use it in GitHub Desktop.
Save mauricioalarcon/1319548 to your computer and use it in GitHub Desktop.
ES html_strip test analuzer
# Delete previous just in case
curl -XDELETE localhost:9200/facettests/facettest/
# Set the mapping for out facet
curl -XPUT localhost:9200/facettests/facettest/_mapping -d '{
"facettest" : {
"properties" : {
"employmentHistory" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : { "type" : "string", "index": "analyzed" },
"nameFacet" : { "type" : "string", "index" : "analyzed", "analyzer" : "keyword" }
}
}
}
}
}
}
}'
# Insert couple of tests
curl -XPOST localhost:9200/facettests/facettest/1 -d '{ "id" : 1,
"name" : "Bob",
"lastName" : "Marley",
"city" : "Boston",
"country" : "United States",
"education" : [ {
"degreeType" : "doctorate",
"major" : "Mathematics",
"schoolName" : "Cornell University"
} ],
"employmentHistory" : [ { "category" : "Senior (more than 5 years experience)",
"name" : "A.M. (honorary), Harvard University",
"title" : "Assistant and Associate Professor, Cornell University"
},
{ "category" : "Senior (more than 5 years experience)",
"name" : "Massachusetts Institute of Technology",
"title" : "Professor"
},
{ "category" : "Senior (more than 5 years experience)",
"name" : "Harvard University",
"title" : "Professor"
},
{ "category" : "Senior (more than 5 years experience)",
"name" : "California Institute of Technology",
"title" : "Fellow"
},
{ "category" : "Senior (more than 5 years experience)",
"name" : "University of Chicago",
"title" : "Visiting Professor"
},
{ "category" : "Senior (more than 5 years experience)",
"name" : "Nate Ackerman, M.I.T. Ph.D",
"title" : "1"
},
{ "category" : "Senior (more than 5 years experience)",
"name" : "Alice Chan, M.I.T",
"title" : "student"
},
{ "category" : "Experienced (non-manager)",
"name" : "Congress of Mathematicians",
"title" : "2"
},
{ "category" : "Experienced (non-manager)",
"name" : "AMS Summer Institute in Recursion Theory",
"title" : "Member"
},
{ "category" : "Senior Executive (President, C-level)",
"name" : "Association for Symbolic Logic",
"title" : "Chairman, awards and prizes"
}
]
}'
curl -XPOST localhost:9200/facettests/facettest/2 -d '{ "id" : 2,
"name" : "Isaac",
"lastName" : "Smith",
"city" : "Lyons",
"country" : "United States",
"educationHistory" : [ {
"degreeType" : "masters",
"major" : "Teaching English as a Second Language",
"schoolName" : "University of Illinois"
},
{
"degreeType" : "bachelors",
"major" : "English",
"schoolName" : "University of Colorado"
}
],
"employmentHistory" : [ { "category" : "Manager",
"name" : "Pillar Data Systems",
"title" : "Senior Technical Writer"
},
{ "category" : "Manager",
"name" : "Monitoring (BAM)",
"title" : "Senior Technical Writer"
},
{ "category" : "Manager",
"name" : "HP Photosmart",
"title" : "Senior Technical Writer"
},
{ "category" : "Experienced (non-manager)",
"name" : "Utility Data Center",
"title" : "Write system administrator documentation for Utility Data Center"
},
{ "category" : "Entry Level",
"name" : "Research Systems",
"title" : null
},
{ "category" : "Entry Level",
"name" : "Univ. of Colorado at Denver",
"title" : "Adjunct Instructor"
}
]
}'
# Test they're there (count, then search)
curl -XGET localhost:9200/facettests/facettest/_count?pretty=true
curl -XGET localhost:9200/facettests/facettest/_search?pretty=true
# facet over degree type
curl -XGET localhost:9200/facettests/facettest/_search?pretty=true -d '{
"fields": [
"_id",
"employmentHistory.name"
],
"query" : {
"match_all" : {}
},
"facets" : {
"degreeFacet" : { "terms" : { "field" : "educationHistory.nameFacet"}},
"degree" : { "terms" : { "field" : "educationHistory.name"}}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment