Skip to content

Instantly share code, notes, and snippets.

@jasocox
Created November 8, 2013 19:26
Show Gist options
  • Save jasocox/7376224 to your computer and use it in GitHub Desktop.
Save jasocox/7376224 to your computer and use it in GitHub Desktop.
Stemming with elastic search. I'm adding an index with "Halls" in the name, and would like it to show up when searching for "hall"
# 2013-11-08 14:00:26:707 [CREATE] ("test_listings")
#
curl -X POST http://localhost:9201/test_listings -d '{"mappings":{"listing":{"properties":{"slug":{"type":"string"},"name":{"analyzer":"snowball","type":"string"},"description":{"type":"string"},"space_type_name":{"as":{},"type":"string"},"usages":{"as":{},"type":"string"},"amenities":{"as":{},"type":"string"},"nearbies":{"as":{},"type":"string"},"tags":{"as":{},"type":"string"},"camera_ok":{"type":"string"},"charitable":{"type":"string"},"accessible":{"type":"string"},"active":{"type":"string"},"demoable":{"as":"activatable?","type":"string"},"location_id":{"type":"string"},"location_slug":{"as":"location_slug","type":"string"},"location_name":{"as":"location_name","type":"string"},"location_lat_lon":{"as":"location_lat_lon","type":"geo_point"},"location_address":{"as":"location_address","index":"not_analyzed","type":"string"},"location_profile_image_url":{"as":"location_profile_image_url","index":"not_analyzed","type":"string"},"usages_for_facet":{"as":{},"index":"not_analyzed","type":"string"},"amenities_for_facet":{"as":{},"index":"not_analyzed","type":"string"},"nearbies_for_facet":{"as":{},"index":"not_analyzed","type":"string"},"image_url":{"as":{},"index":"not_analyzed","type":"string"},"current_availability":{"as":{},"index":"not_analyzed","type":"object"},"tagline":{"index":"not_analyzed","type":"string"},"price_per_person_for_facet":{"as":"current_availability.price_per_person","type":"float"},"hourly_price_for_facet":{"as":"current_availability.hourly_price","type":"float"},"daily_price_for_facet":{"as":"current_availability.daily_price","type":"float"},"weekly_price_for_facet":{"as":"current_availability.weekly_price","type":"float"},"monthly_price_for_facet":{"as":"current_availability.monthly_price","type":"float"},"yearly_price_for_facet":{"as":"current_availability.yearly_price","type":"float"},"metrics":{"as":{},"index":"not_analyzed","type":"object"},"m
etrics_for_facet":{"as":{},"index":"not_analyzed","type":"string"}}}},"settings":{}}'
# 2013-11-08 14:00:26:707 [200]
# 2013-11-08 14:00:26:863 [listing/6] ("test_listings")
#
curl -X POST "http://localhost:9201/test_listings/listing/6" -d '{"accessible":false,"active":true,"camera_ok":null,"charitable":null,"description":null,"location_id":6,"name":"Indy halls","slug":"mystring_indy-halls","tagline":null,"space_type_name":"MyString","usages":[
],"amenities":[],"nearbies":[],"tags":[],"demoable":null,"location_slug":"mystring-mystring","location_name":"MyString","location_lat_lon":null,"location_address":"MyString, MyString, MyString, MyString MyString","location_profile_image_url":null,"usages_for_facet":[],"am
enities_for_facet":[],"nearbies_for_facet":[],"image_url":null,"current_availability":{"hourlyPrice":0.0,"dailyPrice":0.0,"weeklyPrice":0.0,"monthlyPrice":0.0,"yearlyPrice":0.0,"defaultPrice":0.0,"minimumPrice":0.0,"request":null,"pricePerPerson":0.0},"price_per_person_fo
r_facet":null,"hourly_price_for_facet":null,"daily_price_for_facet":null,"weekly_price_for_facet":null,"monthly_price_for_facet":null,"yearly_price_for_facet":null,"metrics":null,"metrics_for_facet":[]}'
# 2013-11-08 14:00:26:863 [201]
# 2013-11-08 14:00:26:881 [_refresh] ("test_listings")
#
curl -X POST "http://localhost:9201/test_listings/_refresh"
# 2013-11-08 14:00:26:882 [200]
# 2013-11-08 14:00:26:908 [_search] (["test_listings"])
#
curl -X GET 'http://localhost:9201/test_listings/listing/_search?size=10&pretty' -d '{"query":{"query_string":{"query":"hall"}},"facets":{"usages":{"terms":{"field":"usages_for_facet","size":40,"all_terms":false},"facet_filter":{"and":[{"bool":{"must":{"term":{"active":tr
ue}}}}]}},"nearbies":{"terms":{"field":"nearbies_for_facet","size":40,"all_terms":false},"facet_filter":{"and":[{"bool":{"must":{"term":{"active":true}}}}]}},"amenities":{"terms":{"field":"amenities_for_facet","size":40,"all_terms":false},"facet_filter":{"and":[{"bool":{"
must":{"term":{"active":true}}}}]}},"camera_ok":{"terms":{"field":"camera_ok","size":10,"all_terms":false},"facet_filter":{"and":[{"bool":{"must":{"term":{"active":true}}}}]}},"charitable":{"terms":{"field":"charitable","size":10,"all_terms":false},"facet_filter":{"and":[
{"bool":{"must":{"term":{"active":true}}}}]}},"accessible":{"terms":{"field":"accessible","size":10,"all_terms":false},"facet_filter":{"and":[{"bool":{"must":{"term":{"active":true}}}}]}},"pricePerPerson":{"statistical":{"field":"price_per_person_for_facet"},"facet_filter
":{"and":[{"bool":{"must":{"term":{"active":true}}}}]}},"hourlyPrice":{"statistical":{"field":"hourly_price_for_facet"},"facet_filter":{"and":[{"bool":{"must":{"term":{"active":true}}}}]}},"dailyPrice":{"statistical":{"field":"daily_price_for_facet"},"facet_filter":{"and"
:[{"bool":{"must":{"term":{"active":true}}}}]}},"weeklyPrice":{"statistical":{"field":"weekly_price_for_facet"},"facet_filter":{"and":[{"bool":{"must":{"term":{"active":true}}}}]}},"monthlyPrice":{"statistical":{"field":"monthly_price_for_facet"},"facet_filter":{"and":[{"
bool":{"must":{"term":{"active":true}}}}]}},"yearlyPrice":{"statistical":{"field":"yearly_price_for_facet"},"facet_filter":{"and":[{"bool":{"must":{"term":{"active":true}}}}]}},"metrics":{"terms":{"field":"metrics_for_facet","size":22,"all_terms":false},"facet_filter":{"a
nd":[{"bool":{"must":{"term":{"active":true}}}}]}}},"filter":{"and":[{"bool":{"must":{"term":{"active":true}}}}]},"size":10}'
# 2013-11-08 14:00:26:909 [200] (5 msec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment