2019-04-03 23:15:33 +02:00
[role="xpack"]
[[maps-search]]
== Searching your data
2019-09-10 23:22:59 +02:00
**Elastic Maps** embeds the search bar for real-time search.
2019-04-03 23:15:33 +02:00
Only layers requesting data from {es} are filtered when you submit a search request.
2019-09-10 23:22:59 +02:00
Layers narrowed by the search context contain the filter icon image:maps/images/filter_icon.png[] to the right of layer name in the legend.
2019-04-03 23:15:33 +02:00
You can create a layer that requests data from {es} from the following:
* <<vector-layer>> with:
** Documents source
** Grid aggregation source
2019-11-18 21:59:27 +01:00
** <<terms-join>>
2019-04-03 23:15:33 +02:00
* <<heatmap-layer>> with Grid aggregation source
[role="screenshot"]
image::maps/images/global_search_bar.png[]
2019-09-10 23:22:59 +02:00
[role="xpack"]
[[maps-create-filter-from-map]]
=== Creating filters from your map
You can create two types of filters by interacting with your map:
* <<maps-spatial-filters, Spatial filters>>
* <<maps-phrase-filter, Phrase filters>>
[float]
[[maps-spatial-filters]]
==== Spatial filters
2019-09-12 23:06:53 +02:00
A spatial filter narrows search results to documents that either intersect with, are within, or do not intersect with the specified geometry.
2019-09-10 23:22:59 +02:00
You can create spatial filters in two ways:
* Click the tool icon image:maps/images/tools_icon.png[], and then draw a polygon or bounding box on the map to define the spatial filter.
2019-10-21 20:02:34 +02:00
* Click *Filter by geometry* in a <<maps-vector-tooltip-locking, locked tooltip>>, and then use the feature's geometry for the spatial filter.
2019-09-10 23:22:59 +02:00
+
[role="screenshot"]
image::maps/images/create_spatial_filter.png[]
Spatial filters have the following properties:
* *Geometry label* enables you to provide a meaningful name for your spatial filter.
* *Spatial field* specifies the geo_point or geo_shape field used to determine if a document matches the spatial relation with the specified geometry.
* *Spatial relation* determines the {ref}/query-dsl-geo-shape-query.html#_spatial_relations[spatial relation operator] to use at search time. Only available when *Spatial field* is set to geo_shape.
[float]
[[maps-phrase-filter]]
==== Phrase filters
A phrase filter narrows search results to documents that contain the specified text.
2019-10-21 20:02:34 +02:00
You can create a phrase filter by clicking the plus icon image:maps/images/gs_plus_icon.png[] in a <<maps-vector-tooltip-locking, locked tooltip>>.
2019-09-10 23:22:59 +02:00
[role="screenshot"]
image::maps/images/create_phrase_filter.png[]
2019-04-03 23:15:33 +02:00
2019-04-19 17:58:02 +02:00
[role="xpack"]
[[maps-layer-based-filtering]]
=== Filtering a single layer
You can apply a search request to individual layers by setting `Filters` in the layer details panel.
Click the *Add filter* button to add a filter to a layer.
2019-06-26 17:56:23 +02:00
NOTE: Layer filters are not applied to *term joins*. You can apply a search request to *term joins* by setting the *where* clause in the join definition.
2019-04-19 17:58:02 +02:00
[role="screenshot"]
image::maps/images/layer_search.png[]
[role="xpack"]
[[maps-search-across-multiple-indices]]
2019-04-03 23:15:33 +02:00
=== Searching across multiple indices
Your map might contain multiple {es} indices.
This can occur when your map contains two or more layers with {es} sources from different indices.
This can also occur with a single layer with an {es} source and a <<terms-join>>.
Searching across multiple indices might sometimes result in empty layers.
The most common cause for empty layers are searches for a field that exists in one index, but does not exist in other indices.
2019-09-10 23:22:59 +02:00
[float]
[[maps-disable-search-for-layer]]
==== Disable search for layer
2019-11-18 21:59:27 +01:00
You can prevent the search bar from applying search context to a layer by configuring the following:
2019-12-11 21:53:58 +01:00
* In *Filtering*, clear the *Apply global filter to layer data* checkbox to turn off the global search context for the layer source.
2019-11-18 21:59:27 +01:00
* In *Term joins*, clear the *Apply global filter to join* checkbox to turn off the global search context for the <<terms-join, term join>>.
2019-09-10 23:22:59 +02:00
[float]
[[maps-add-index-search]]
==== Use _index in your search
2019-04-03 23:15:33 +02:00
Add {ref}/mapping-index-field.html[_index] to your search to include documents from indices that do not contain a search field.
For example, suppose you have a vector layer showing the `kibana_sample_data_logs` documents
and another vector layer with `kibana_sample_data_flights` documents.
(See <<add-sample-data, adding sample data>>
to install the `kibana_sample_data_logs` and `kibana_sample_data_flights` indices.)
If you query for
--------------------------------------------------
machine.os.keyword : "osx"
--------------------------------------------------
the `kibana_sample_data_flights` layer is empty because the index
`kibana_sample_data_flights` does not contain the field `machine.os.keyword` and no documents match the query.
[role="screenshot"]
image::maps/images/global_search_multiple_indices_query1.png[]
If you instead query for
--------------------------------------------------
machine.os.keyword : "osx" or _index : "kibana_sample_data_flights"
--------------------------------------------------
the `kibana_sample_data_flights` layer includes data.
[role="screenshot"]
image::maps/images/global_search_multiple_indices_query2.png[]