Skip to content

Instantly share code, notes, and snippets.

@josiahbryan
Last active December 5, 2016 08:00
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 josiahbryan/df828752aef7147da979828784e21bcc to your computer and use it in GitHub Desktop.
Save josiahbryan/df828752aef7147da979828784e21bcc to your computer and use it in GitHub Desktop.
Problem with OR Search in ElasticSearch 5
PUT /my_index/
{
"mappings": {
"data": {
"properties": {
"_stringified": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"account_validated": {
"type": "boolean"
},
"address": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"address1": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"birth_date": {
"type": "date",
"format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"cell_phone": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"chart_num": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"city": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"comments": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"country": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"current_photo_url": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"date_lastvisit": {
"type": "date",
"format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"date_started": {
"type": "date",
"format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"deleted": {
"type": "boolean"
},
"discount": {
"type": "float"
},
"doctorid": {
"type": "long"
},
"doctorid_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"email": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"emergency_contact_name": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"emergency_contact_phone": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"emergency_contact_relation": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"exam_procd": {
"type": "long"
},
"exam_procd_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"external_id": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"filos_contactid": {
"type": "long"
},
"filos_contactid_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"first": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"has_text_consent": {
"type": "long"
},
"home_phone": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"ins_primary_group_num": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"ins_primary_payer": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"ins_primary_payer_id": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"ins_primary_payer_id_num": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"ins_primary_plan": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"is_deceased": {
"type": "keyword",
"fields": {
"english": {
"type": "text",
"analyzer": "english"
}
}
},
"is_inactive": {
"type": "keyword",
"fields": {
"english": {
"type": "text",
"analyzer": "english"
}
}
},
"is_starred": {
"type": "boolean"
},
"last": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"last_nutsched_edit": {
"type": "date",
"format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"marital_status": {
"type": "keyword",
"fields": {
"english": {
"type": "text",
"analyzer": "english"
}
}
},
"marketing_source": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"merge_note": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"mergeid": {
"type": "long"
},
"mergeid_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"middle": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"num_visits": {
"type": "long"
},
"officeid": {
"type": "long"
},
"officeid_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"patientid": {
"type": "long"
},
"post_validate_url": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"preferred": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"qb_listid": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"reeval_days": {
"type": "long"
},
"sched_procd": {
"type": "long"
},
"sched_procd_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"schededit_datetime": {
"type": "date",
"format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"schededit_open_flag": {
"type": "long"
},
"schededit_pin": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"schededit_userid": {
"type": "long"
},
"schededit_userid_string": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"sex": {
"type": "keyword",
"fields": {
"english": {
"type": "text",
"analyzer": "english"
}
}
},
"ssn": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"star_reason": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"state": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"temp_pass": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"url": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"user_pass": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"validation_code": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"wants_email_reminders": {
"type": "long"
},
"wants_phone_reminders": {
"type": "long"
},
"wants_text_reminders": {
"type": "long"
},
"work_phone": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
},
"zip": {
"type": "text",
"fields": {
"autocomplete": {
"type": "text",
"analyzer": "autocomplete"
},
"autocomplete_english": {
"type": "text",
"analyzer": "trigram_english"
},
"english": {
"type": "text",
"analyzer": "english"
},
"keyword": {
"type": "keyword",
"ignore_above": 256
},
"reverse": {
"type": "text",
"analyzer": "reverse"
},
"shingle": {
"type": "text",
"analyzer": "shingle"
},
"shingle_english": {
"type": "text",
"analyzer": "shingle_english"
},
"trigram": {
"type": "text",
"analyzer": "trigram"
},
"trigram_english": {
"type": "text",
"analyzer": "trigram_english"
}
}
}
}
}
},
"settings": {
"index": {
"analysis": {
"filter": {
"shingle": {
"max_shingle_size": "3",
"min_shingle_size": "2",
"type": "shingle"
},
"english_stemmer": {
"type": "stemmer",
"language": "english"
},
"english_possessive_stemmer": {
"type": "stemmer",
"language": "possessive_english"
},
"trigrams_filter": {
"type": "ngram",
"min_gram": "3",
"max_gram": "3"
},
"english_stop": {
"type": "stop",
"stopwords": "_english_"
},
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "20"
}
},
"analyzer": {
"trigram": {
"filter": [
"lowercase",
"trigrams_filter"
],
"type": "custom",
"tokenizer": "standard"
},
"autocomplete_english": {
"filter": [
"english_possessive_stemmer",
"lowercase",
"english_stop",
"english_stemmer",
"autocomplete_filter"
],
"type": "custom",
"tokenizer": "standard"
},
"shingle_english": {
"filter": [
"english_possessive_stemmer",
"lowercase",
"english_stop",
"english_stemmer",
"shingle"
],
"type": "custom",
"tokenizer": "standard"
},
"autocomplete": {
"filter": [
"lowercase",
"autocomplete_filter"
],
"type": "custom",
"tokenizer": "standard"
},
"shingle": {
"filter": [
"lowercase",
"standard",
"shingle"
],
"type": "custom",
"tokenizer": "standard"
},
"reverse": {
"filter": [
"lowercase",
"standard",
"reverse"
],
"type": "custom",
"tokenizer": "standard"
},
"trigram_english": {
"filter": [
"english_possessive_stemmer",
"lowercase",
"english_stop",
"english_stemmer",
"trigrams_filter"
],
"type": "custom",
"tokenizer": "standard"
}
}
}
}
}
}
PUT /my_index/data/80346
{
"home_phone": "",
"date_lastvisit": null,
"schededit_open_flag": "0",
"email": "j@gmail.com",
"last_nutsched_edit": "2016-11-15 09:09:27",
"wants_text_reminders": "1",
"ins_primary_payer_id_num": "",
"url": "/office/patients/80346",
"validation_code": "",
"date_started": null,
"account_validated": "0",
"middle": "",
"has_text_consent": "0",
"qb_listid": "",
"mergeid_string": "",
"cell_phone": "",
"user_pass": "",
"is_deceased": "No",
"sched_procd": "",
"ins_primary_plan": "",
"ins_primary_group_num": "",
"num_visits": "0",
"country": "",
"post_validate_url": "",
"emergency_contact_relation": "",
"last": "Bryan",
"deleted": "0",
"merge_note": "",
"temp_pass": "",
"filos_contactid": "",
"wants_email_reminders": "1",
"ins_primary_payer_id": "",
"chart_num": "",
"is_starred": "0",
"ins_primary_payer": "",
"comments": "",
"state": "",
"address": "",
"officeid": "4",
"emergency_contact_name": "",
"work_phone": "",
"_stringified": "Josiah Bryan",
"filos_contactid_string": "",
"schededit_pin": "",
"patientid": "80346",
"exam_procd": "",
"is_inactive": "No",
"discount": "45",
"zip": "",
"external_id": "",
"exam_procd_string": "",
"officeid_string": "Whole Health Associates",
"mergeid": "",
"address1": "",
"star_reason": "",
"marital_status": "Widowed",
"current_photo_url": "",
"schededit_userid": "0",
"city": "",
"ssn": "",
"doctorid": "",
"schededit_userid_string": "",
"schededit_datetime": null,
"first": "Josiah",
"emergency_contact_phone": "",
"reeval_days": "0",
"marketing_source": "",
"preferred": "",
"birth_date": null,
"sex": "Male",
"doctorid_string": "",
"sched_procd_string": "",
"wants_phone_reminders": "0"
}
PUT /my_index/data/209
{
"home_phone": "",
"date_lastvisit": null,
"schededit_open_flag": "0",
"email": "j@gmail.com",
"last_nutsched_edit": null,
"wants_text_reminders": "1",
"ins_primary_payer_id_num": "",
"url": "/office/patients/209",
"validation_code": "",
"date_started": null,
"account_validated": "0",
"middle": "",
"has_text_consent": "1",
"qb_listid": "",
"mergeid_string": "",
"cell_phone": "",
"user_pass": "",
"is_deceased": "No",
"sched_procd": "",
"ins_primary_plan": "",
"ins_primary_group_num": "",
"num_visits": "0",
"country": "",
"post_validate_url": "",
"emergency_contact_relation": "",
"last": "Bryan",
"deleted": "0",
"merge_note": "",
"temp_pass": "",
"filos_contactid": "",
"wants_email_reminders": "1",
"ins_primary_payer_id": "",
"chart_num": "",
"is_starred": "0",
"ins_primary_payer": "",
"comments": "",
"state": "",
"address": "",
"officeid": "2",
"emergency_contact_name": "",
"work_phone": "",
"_stringified": "Josiah Bryan",
"filos_contactid_string": "",
"schededit_pin": "",
"patientid": "209",
"exam_procd": "",
"is_inactive": "No",
"discount": "50",
"zip": "",
"external_id": "",
"exam_procd_string": "",
"officeid_string": "Reid Chiropractic",
"mergeid": "",
"address1": "",
"star_reason": "",
"marital_status": "?",
"current_photo_url": "/office/patients/209/blobs/144/raw/.patientphoto.jpg",
"schededit_userid": "0",
"city": "",
"ssn": "",
"doctorid": "",
"schededit_userid_string": "",
"schededit_datetime": null,
"first": "Josiah",
"emergency_contact_phone": "",
"reeval_days": "30",
"marketing_source": "",
"preferred": "",
"birth_date": null,
"sex": "Male",
"doctorid_string": "",
"sched_procd_string": "",
"wants_phone_reminders": "0"
}
GET /my_index/_search
{
"_source": ["_stringified","officeid"],
"query": {
"bool": {
"should": [
{
"term": {
"officeid": "4"
}
},
{
"bool": {
"must_not": {
"exists": {
"field": "officeid"
}
}
}
}
],
"must":[
{
"multi_match": {
"query": "josiah bryan",
"fields": [
"_stringified",
"_stringified.english",
"_stringified.trigram",
"_stringified.autocomplete",
"_stringified.shingle",
"_stringified.shingle_english",
"_stringified.trigram_english",
"_stringified.autocomplete_english",
"_stringified.reverse",
"_stringified.keyword"
],
"type": "most_fields",
"fuzziness" : "AUTO"
}
}
]
}
},
"highlight": {
"fields": {
"_stringified":{}
}
}
}
// Search returns the following, but should only match the first document since it's the only one with the "officeid" field of "4"
{
"took": 29,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 8.593626,
"hits": [
{
"_index": "my_index",
"_type": "data",
"_id": "80346",
"_score": 8.593626,
"_source": {
"officeid": "4",
"_stringified": "Josiah Bryan"
},
"highlight": {
"_stringified": [
"<em>Josiah</em> <em>Bryan</em>"
]
}
},
{
"_index": "my_index",
"_type": "data",
"_id": "209",
"_score": 7.5936255,
"_source": {
"officeid": "2",
"_stringified": "Josiah Bryan"
},
"highlight": {
"_stringified": [
"<em>Josiah</em> <em>Bryan</em>"
]
}
}
]
}
}
/////// GAHHH!!! The answer was so simple - just had to move the "should" INSIDE the "must" - crikey. Here's the working _search:
GET /my_index/_search
{
"_source": ["_stringified","officeid","officeid_string"],
"query": {
"bool": {
"must":[
{
"bool": {
"should": [
{
"term": {
"officeid": "4"
}
},
{
"bool": {
"must_not": {
"exists": {
"field": "officeid"
}
}
}
},
{
"term": {
"system": "1"
}
}
]
}
},
{
"multi_match": {
"query": "josiah bryan",
"fields": [
"_stringified",
"_stringified.english",
"_stringified.trigram",
"_stringified.autocomplete",
"_stringified.shingle",
"_stringified.shingle_english",
"_stringified.trigram_english",
"_stringified.autocomplete_english",
"_stringified.reverse",
"_stringified.keyword"
],
"type": "most_fields",
"fuzziness" : "AUTO"
}
}
]
}
},
"highlight": {
"fields": {
"_stringified":{}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment