Skip to content

Instantly share code, notes, and snippets.

@mmcachran
Last active January 12, 2021 13:12
Show Gist options
  • Save mmcachran/4104bf7f2917b9617f50 to your computer and use it in GitHub Desktop.
Save mmcachran/4104bf7f2917b9617f50 to your computer and use it in GitHub Desktop.
ElasticSearch Notes
== VM for local dev ==
https://github.com/mmcachran/vagrant-elasticsearch-cluster
Add to WP config or in EP settings:
define( 'EP_HOST', 'http://10.0.0.11:9200' );
Indexing your local
wp elasticpress index --setup --network-wide
== To index large multinetwork sites ==
1. Create the mapping - `wp elasticpress put-mapping --network-wide`
2. Create the network alias - `wp elasticpress recreate-network-alias`
3. Index the sites you want - `wp elasticpress index --posts-per-page=100 --url=<url to the site>
Enable Dynamic Scripting
# Enable dynamic scripting.
script.inline: true
script.indexed: true
script.disable_dynamic: false
2016 Ignite talk
https://docs.google.com/presentation/d/1KfprlUW11e6YLBpew4kl-XNa7Ry1AZsQYPn-cHpQox4/edit#slide=id.g17947aba4b_0_89
== Bash loop to reindex a list of sites ==
for i in $(cat ~/sitelist); do echo "Entering site ""$i"; wp elasticpress index --posts-per-page=10 --url="ax.help.int.dynamics.com/""$i"; done
== Commands ==
/_settings?pretty=true Gets defined filters and analyzers
/_mapping?pretty=true Gets current mapping
/_analyze/?text=<some text> Analyzes text and shows tokens
/_flush Clear ES cache
/_search?pretty&q=_id:<post_id> Search for posts with a certain ID.
/_cat/indices See all indices
/_stats See all and per index stats
/_search/?explain Explain scores for the query
== Helpful WP Plugins ==
https://github.com/10up/ElasticPress
https://wordpress.org/plugins/debug-bar/
https://wordpress.org/plugins/debug-bar-elasticpress/
== Decay Functions ==
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-decay
== Scripting ==
https://qbox.io/blog/introduction-to-elasticsearch-scripting
== Aggregations ==
https://qbox.io/blog/elasticsearch-aggregations
== Combining Filters ==
https://www.elastic.co/guide/en/elasticsearch/guide/current/combining-filters.html
== Sorting ==
https://www.elastic.co/guide/en/elasticsearch/guide/current/_sorting.html
== Constant Score (featured posts query) ==
http://www.fullscale.co/blog/2013/01/24/Implementing_Featured_Results_With_ElasticSearch.html
== Word Deliminator (special characters) ==
http://www.fullscale.co/blog/2013/03/04/preserving_specific_characters_during_tokenizing_in_elasticsearch.html
== Boosting and narrowing search results ==
https://www.elastic.co/guide/en/elasticsearch/guide/current/_boosting_query_clauses.html
https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html
Boosting with a caret: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html
== Advanced Scoring ==
http://jontai.me/blog/2013/01/advanced-scoring-in-elasticsearch/
http://www.waitingforcode.com/elasticsearch/scoring-and-boosting-in-elasticsearch/read
http://blog.tryolabs.com/2015/03/04/optimizing-elasticsearch-rescoring-queries-with-multi-type-fields/
== Stopwords ==
https://www.elastic.co/blog/stop-stopping-stop-words-a-look-at-common-terms-query
== Shingles ==
https://www.elastic.co/blog/searching-with-shingles
== Interesting Articles ==
http://gibrown.com/2013/01/24/elasticsearch-five-things-i-was-doing-wrong/
== Gists ==
https://gist.github.com/jenwachter/30fe30d6714781a3d0ed
== Pagination with custom sorting ==
https://www.elastic.co/guide/en/elasticsearch/reference/2.0/search-request-preference.html
== Cheat Sheet ==
http://elasticsearch-cheatsheet.jolicode.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment