Skip to content

Instantly share code, notes, and snippets.

View gibrown's full-sized avatar

Greg Ichneumon Brown gibrown

View GitHub Profile
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"hits": {
"total": 422,
@gibrown
gibrown / gist:5577521
Created May 14, 2013 16:53
Modifications for our main app of es-backbone.js between 0.1 and 0.2 of the es-backbone.js lib. I haven't had time to update the sample code in the lib, so hopefully this diff of our application helps show how to use what has changed.
Index: wpes-mgs-p2.css
===================================================================
--- wpes-mgs-p2.css (revision 53507)
+++ wpes-mgs-p2.css (working copy)
@@ -13,7 +13,6 @@
div#wpes-p2-header {
border-bottom: 1px solid #ccc;
- padding: 20px 30px;
}
@gibrown
gibrown / gist:4323746
Created December 18, 2012 00:23
ES fails when match_all filter uses an empty array with a faceted search.
SERVER="http://localhost:9200"
curl -XPUT "$SERVER/bugs/page/8872248-p-145" -d '{"id":145,"url":"http://alexsandbox.wordpress.com/header-test/","date":"2010-02-06 05:23:27","date_gmt":"2010-02-06 05:23:27","author":"Alex Mills","author_login":"viper007bond","title":"Header Test","content":"asdfasd as sad f","category":"Uncategorized","meta":{"_edit_lock":["1337928058:50392"],"_edit_last":["50392"],"_thumbnail_id":["147"]},"meta_raw":{"_edit_lock":["1337928058:50392"],"_edit_last":["50392"],"_thumbnail_id":["147"]}}'
curl -XGET "$SERVER/bugs/_search?pretty" -d '
{
"query":{"filtered":{"query":{"multi_match":{"query":"automattic","fields":["title","content"]}},"filter":{"match_all":{}}}},
"facets" : {
"tag" : {
"terms" : {
diff --git a/src/common/class.wpes-analyzer-builder.php b/src/common/class.wpes-analyzer-builder.php
index 0357ea4..5787479 100644
--- a/src/common/class.wpes-analyzer-builder.php
+++ b/src/common/class.wpes-analyzer-builder.php
@@ -340,6 +340,29 @@ class WPES_Analyzer_Builder {
continue;
}
+ if ( 'de' == $lang ) {
+ ////From: http://gibrown.wordpress.com/2013/05/01/three-principles-for-multilingal-indexing-in-elasticsearch/#comment-857
@gibrown
gibrown / gist:1586723
Created January 10, 2012 03:32
Profiling queries for building word clouds
#word histogram query - docs for separate ids in separate types
curl -XGET "${SERVER}/pd-0/${ID}/_search?pretty" \
-d '{
"size" : 0,
"query" : { "match_all" : { } },
"facets" : {
"q1" : {
"terms" : {
"field" : "q1",
"size" : 100
@gibrown
gibrown / gist:1571828
Created January 6, 2012 18:37
ElasticSearch server state after adding 10's of thousands of types.
Cluster Health:
{
"cluster_name" : "es_cluster_dev",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 15,
"active_shards" : 15,
"relocating_shards" : 0,
@gibrown
gibrown / gist:9419022
Created March 7, 2014 20:11
WP.com related posts query building
public static function post( $blog_id, $post_id, $mlt_fields = array( 'mlt_content' ), $analyzer = false ) {
switch_to_blog( $blog_id );
$post = get_post( $post_id );
$fld_bldr = new ES_WP_Field_Builder();
$tax_data = $fld_bldr->taxonomy( $post );
$mlt_content = $fld_bldr->mlt_content( array(
'title' => $fld_bldr->clean_string( $post->post_title ),
'content' => $fld_bldr->clean_string( $post->post_content ),