Skip to content

Instantly share code, notes, and snippets.

@MagmaRules
Created July 18, 2013 10:05
Show Gist options
  • Save MagmaRules/6028216 to your computer and use it in GitHub Desktop.
Save MagmaRules/6028216 to your computer and use it in GitHub Desktop.
Query for "fragment_size doesn't work with quoted phrase" issue (https://github.com/elasticsearch/elasticsearch/issues/1072?source=c)
{
"from": 0,
"size": 10,
"query": {
"custom_score": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "t-vida",
"fields": [
"TipoEntidade",
"Titulo",
"Descricao",
"Conteudo",
"NrApolice",
"NrCliente",
"NrOcorrencia",
"NrRecibo",
"NrSinistro",
"TipoRecibo",
"CaseId",
"Processo",
"Workflow",
"DocID",
"SerieDocumental",
"text"
],
"use_dis_max": true
}
},
"filter": {
"and": {
"filters": [
{
"bool": {
"should": {
"term": {
"CONF_EMPRESA.facet": "001"
}
}
}
},
{
"query": {
"query_string": {
"query": "(CONF_DOCUMENTO_PUBLICO:True)"
}
}
}
]
}
}
}
},
"script": "type=doc['TipoEntidade.facet'].value;val=['APOLICE':3,'SINISTRO':2,'CLIENTE':1][type]; (_score * 1000) + ((val != null)? val : 0);"
}
},
"fields": [
"TipoEntidade",
"Titulo",
"Empresa",
"Descricao",
"URI_Navegacao",
"URI_Navegacao_UNIX",
"Conteudo",
"NrApolice",
"NrCliente",
"NrOcorrencia",
"NrRecibo",
"NrSinistro",
"CaseId",
"Processo",
"Workflow",
"DocID",
"SerieDocumental",
"NrApoliceMae",
"NrReclamante",
"DtIndexacao",
"TipoDocumento",
"id",
"text"
],
"facets": {
"TipoEntidade.facet": {
"terms": {
"field": "TipoEntidade.facet",
"size": 5
}
},
"CONF_EMPRESA.facet": {
"terms": {
"field": "CONF_EMPRESA.facet",
"size": 5
}
}
},
"highlight": {
"fields": {
"text": {
"fragment_size": 100,
"number_of_fragments": 3
}
}
}
}
{
"from": 0,
"size": 10,
"query": {
"custom_score": {
"query": {
"filtered": {
"query": {
"query_string": {
"query": "+\"t-vida\"",
"fields": [
"TipoEntidade",
"Titulo",
"Descricao",
"Conteudo",
"NrApolice",
"NrCliente",
"NrOcorrencia",
"NrRecibo",
"NrSinistro",
"TipoRecibo",
"CaseId",
"Processo",
"Workflow",
"DocID",
"SerieDocumental",
"text"
],
"use_dis_max": true
}
},
"filter": {
"and": {
"filters": [
{
"bool": {
"should": {
"term": {
"CONF_EMPRESA.facet": "001"
}
}
}
},
{
"query": {
"query_string": {
"query": "(CONF_DOCUMENTO_PUBLICO:True)"
}
}
}
]
}
}
}
},
"script": "type=doc['TipoEntidade.facet'].value;val=['APOLICE':3,'SINISTRO':2,'CLIENTE':1][type]; (_score * 1000) + ((val != null)? val : 0);"
}
},
"fields": [
"TipoEntidade",
"Titulo",
"Empresa",
"Descricao",
"URI_Navegacao",
"URI_Navegacao_UNIX",
"Conteudo",
"NrApolice",
"NrCliente",
"NrOcorrencia",
"NrRecibo",
"NrSinistro",
"CaseId",
"Processo",
"Workflow",
"DocID",
"SerieDocumental",
"NrApoliceMae",
"NrReclamante",
"DtIndexacao",
"TipoDocumento",
"id",
"text"
],
"facets": {
"TipoEntidade.facet": {
"terms": {
"field": "TipoEntidade.facet",
"size": 5
}
},
"CONF_EMPRESA.facet": {
"terms": {
"field": "CONF_EMPRESA.facet",
"size": 5
}
}
},
"highlight": {
"fields": {
"text": {
"fragment_size": 100,
"number_of_fragments": 3
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment