Need Exact Search on Two Fields


(Randy Jensen) #1

I need to be able to do an exact search against two fields, Program Heading
and Subheading each with it's own search term.

For example, I might need to search for Health Professions -> Medical. So
the Program Area field would be "Health Professions" and the Subheading
field would be "Medical". Again, I need exact searched, so "Medical
Marketing" wouldn't come back as a Subheading if "Medical" is searched for
or if Medical appears as a subheading under another Program Area.

I've tried every variation of every query I can think of and can't get it
exactly right. I have the mapping below:

'properties' => array(
'program_area' => array(
'type' => 'multi_field',
'fields' => array(
'program_area' => array(
'type' => 'string',
'index' => 'analyzed'
),
'program_area_raw' => array(
'type' => 'string',
'index' => 'not_analyzed',
'store' => true
)
)
),
'subheading' => array(
'type' => 'multi_field',
'fields' => array(
'subheading' => array(
'type' => 'string',
'index' => 'analyzed',
'store' => true
),
'subheading_raw' => array(
'type' => 'string',
'index' => 'not_analyzed',
'store' => true
)
)
),
)

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/705e6394-1edc-4236-bbf1-a4f6b22f0eb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Binh Ly-2) #2

What happens if you try searching only on the _raw fields, like for example:

{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": { "program_area_raw": "Health Professions" }
},
{
"term": { "subheading_raw": "Medical" }
}
]
}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ac2398bb-bd53-4e1e-b0a3-8b7fc0bf2b49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3