2010-02-17 09:28:06 +02:00
|
|
|
/*
|
2011-12-06 02:42:25 +02:00
|
|
|
* Licensed to ElasticSearch and Shay Banon under one
|
2010-02-17 09:28:06 +02:00
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
2011-12-06 02:42:25 +02:00
|
|
|
* regarding copyright ownership. ElasticSearch licenses this
|
2010-02-17 09:28:06 +02:00
|
|
|
* file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.elasticsearch.rest.action;
|
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
import com.google.common.collect.Lists;
|
2010-06-15 16:51:38 +03:00
|
|
|
import org.elasticsearch.common.inject.AbstractModule;
|
2011-02-10 17:23:49 +01:00
|
|
|
import org.elasticsearch.rest.BaseRestHandler;
|
2010-02-24 23:16:01 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.health.RestClusterHealthAction;
|
2012-08-02 14:52:31 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.node.hotthreads.RestNodesHotThreadsAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.node.info.RestNodesInfoAction;
|
2010-05-01 03:00:06 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.node.restart.RestNodesRestartAction;
|
2010-03-17 00:29:36 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.node.shutdown.RestNodesShutdownAction;
|
2010-05-09 09:59:43 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.node.stats.RestNodesStatsAction;
|
2011-10-16 19:02:32 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.reroute.RestClusterRerouteAction;
|
2011-08-20 04:00:41 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.settings.RestClusterGetSettingsAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.cluster.settings.RestClusterUpdateSettingsAction;
|
2013-03-05 07:24:07 -05:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.shards.RestClusterSearchShardsAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.state.RestClusterStateAction;
|
2013-07-23 15:32:56 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.cluster.tasks.RestPendingClusterTasksAction;
|
2011-05-19 00:21:59 -04:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.alias.RestGetIndicesAliasesAction;
|
2010-03-25 02:00:53 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.alias.RestIndicesAliasesAction;
|
2013-05-17 12:29:24 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.alias.delete.RestIndexDeleteAliasesAction;
|
2013-07-15 14:55:46 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.alias.get.RestGetAliasesAction;
|
2013-07-15 14:28:09 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.alias.head.RestAliasesExistAction;
|
2013-05-17 12:29:24 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.alias.put.RestIndexPutAliasAction;
|
2010-11-21 17:33:35 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.analyze.RestAnalyzeAction;
|
2010-04-01 12:25:51 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.cache.clear.RestClearIndicesCacheAction;
|
2010-10-23 21:52:09 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.close.RestCloseIndexAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.create.RestCreateIndexAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.indices.delete.RestDeleteIndexAction;
|
2012-09-20 18:10:56 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.exists.indices.RestIndicesExistsAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.indices.exists.types.RestTypesExistsAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.flush.RestFlushAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.indices.gateway.snapshot.RestGatewaySnapshotAction;
|
2010-09-16 14:35:07 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.mapping.delete.RestDeleteMappingAction;
|
2013-10-14 08:53:07 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.mapping.get.RestGetFieldMappingAction;
|
2010-06-17 17:56:07 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.mapping.get.RestGetMappingAction;
|
2010-02-21 16:49:42 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.mapping.put.RestPutMappingAction;
|
2010-10-23 21:52:09 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.open.RestOpenIndexAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.optimize.RestOptimizeAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.indices.refresh.RestRefreshAction;
|
2011-06-26 00:20:50 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.segments.RestIndicesSegmentsAction;
|
2011-03-29 13:50:25 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.settings.RestGetSettingsAction;
|
2010-08-08 09:17:09 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.settings.RestUpdateSettingsAction;
|
2011-08-24 11:24:52 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.stats.RestIndicesStatsAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.status.RestIndicesStatusAction;
|
2010-11-26 15:45:18 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.template.delete.RestDeleteIndexTemplateAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.indices.template.get.RestGetIndexTemplateAction;
|
2013-08-04 13:51:34 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.template.head.RestHeadIndexTemplateAction;
|
2010-11-26 15:45:18 +02:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.template.put.RestPutIndexTemplateAction;
|
2011-12-28 15:24:08 -07:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.validate.query.RestValidateQueryAction;
|
2012-05-06 18:50:35 +03:00
|
|
|
import org.elasticsearch.rest.action.admin.indices.warmer.delete.RestDeleteWarmerAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.indices.warmer.get.RestGetWarmerAction;
|
|
|
|
import org.elasticsearch.rest.action.admin.indices.warmer.put.RestPutWarmerAction;
|
2010-09-15 12:22:07 +02:00
|
|
|
import org.elasticsearch.rest.action.bulk.RestBulkAction;
|
2013-10-30 10:08:31 -05:00
|
|
|
import org.elasticsearch.rest.action.cat.RestAllocationAction;
|
|
|
|
import org.elasticsearch.rest.action.cat.RestShardsAction;
|
|
|
|
import org.elasticsearch.rest.action.cat.RestIndicesAction;
|
|
|
|
import org.elasticsearch.rest.action.cat.RestMasterAction;
|
|
|
|
import org.elasticsearch.rest.action.cat.RestNodesAction;
|
|
|
|
import org.elasticsearch.rest.action.cat.RestRecoveryAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.delete.RestDeleteAction;
|
|
|
|
import org.elasticsearch.rest.action.deletebyquery.RestDeleteByQueryAction;
|
2012-08-20 18:06:36 +02:00
|
|
|
import org.elasticsearch.rest.action.explain.RestExplainAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.get.RestGetAction;
|
2013-05-06 12:55:32 +02:00
|
|
|
import org.elasticsearch.rest.action.get.RestGetSourceAction;
|
2012-06-22 19:32:38 +02:00
|
|
|
import org.elasticsearch.rest.action.get.RestHeadAction;
|
2011-06-27 22:23:49 +03:00
|
|
|
import org.elasticsearch.rest.action.get.RestMultiGetAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.index.RestIndexAction;
|
|
|
|
import org.elasticsearch.rest.action.main.RestMainAction;
|
2010-02-27 03:57:36 +02:00
|
|
|
import org.elasticsearch.rest.action.mlt.RestMoreLikeThisAction;
|
2013-08-11 23:11:18 +02:00
|
|
|
import org.elasticsearch.rest.action.percolate.RestMultiPercolateAction;
|
2011-01-13 16:20:31 +02:00
|
|
|
import org.elasticsearch.rest.action.percolate.RestPercolateAction;
|
2013-09-10 21:16:47 +02:00
|
|
|
import org.elasticsearch.rest.action.search.RestClearScrollAction;
|
2012-02-20 18:57:27 +02:00
|
|
|
import org.elasticsearch.rest.action.search.RestMultiSearchAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
import org.elasticsearch.rest.action.search.RestSearchAction;
|
2010-03-21 01:14:49 +02:00
|
|
|
import org.elasticsearch.rest.action.search.RestSearchScrollAction;
|
# REST Suggester API
The REST Suggester API binds the 'Suggest API' to the REST Layer directly. Hence there is no need to touch the query layer for requesting suggestions.
This API extracts the Phrase Suggester API and makes 'suggestion request' top-level objects in suggestion requests. The complete API can be found in the
underlying ["Suggest Feature API"](http://www.elasticsearch.org/guide/reference/api/search/suggest.html).
# API Example
The following examples show how Suggest Actions work on the REST layer. According to this a simple request and its response will be shown.
## Suggestion Request
```json
curl -XPOST 'localhost:9200/_suggest?pretty=true' -d '{
"text" : "Xor the Got-Jewel",
"simple_phrase" : {
"phrase" : {
"analyzer" : "bigram",
"field" : "bigram",
"size" : 1,
"real_word_error_likelihood" : 0.95,
"max_errors" : 0.5,
"gram_size" : 2
}
}
}'
```
This example shows how to query a suggestion for the global text 'Xor the Got-Jewel'. A 'simple phrase' suggestion is requested and
a 'direct generator' is configured to generate the candidates.
## Suggestion Response
On success the request above will reply with a response like the following:
```json
{
"simple_phrase" : [ {
"text" : "Xor the Got-Jewel",
"offset" : 0,
"length" : 17,
"options" : [ {
"text" : "xorr the the got got jewel",
"score" : 3.5283546E-4
} ]
} ]
}
```
The 'suggest'-response contains a single 'simple phrase' which contains an 'option' in turn. This option represents a suggestion of the
queried text. It contains the corrected text and a score indicating the probability of this option to be meant.
Closes #2774
2013-03-11 17:39:18 +01:00
|
|
|
import org.elasticsearch.rest.action.suggest.RestSuggestAction;
|
Multi term vector request
--------------------------
This feature allows to retrieve [term vectors](https://github.com/elasticsearch/elasticsearch/issues/3114) for a list of documents. The json request has exactly the same [format](https://github.com/elasticsearch/elasticsearch/issues/3484) as the ```_termvectors``` endpoint
It use it, call
```
curl -XGET 'http://localhost:9200/index/type/_mtermvectors' -d '{
"fields": [
"field1",
"field2",
...
],
"ids": [
"docId1",
"docId2",
...
],
"offsets": false|true,
"payloads": false|true,
"positions": false|true,
"term_statistics": false|true,
"field_statistics": false|true
}'
```
The return format is an array, each entry of which conatins the term vector response for one document:
```
{
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "docId1",
"_version": 1,
"exists": true,
"term_vectors": {
...
}
},
{
"_index": "index",
"_type": "type",
"_id": "docId2",
"_version": 1,
"exists": true,
"term_vectors": {
...
}
}
]
}
```
Note that, like term vectors, the mult term vectors request will silenty skip over documents that have no term vectors stored in the index and will simply return an empty response in this case.
Closes #3536
2013-08-23 18:32:22 +02:00
|
|
|
import org.elasticsearch.rest.action.termvector.RestMultiTermVectorsAction;
|
term vector request
================================
Returns information and statistics on terms in the fields of a particular document as stored in the index.
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true'
Tree types of values can be requested: term information, term statistics and field statistics.
By default, all term information and field statistics are returned for all fields but no term statistics.
Optionally, you can specify the fields for which the information is retrieved either with a parameter in the url
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?fields=text,...'
or adding by adding the requested fields in the request body (see example below).
Term information
-------------------------
- term frequency in the field (always returned)
- term positions ("positions" : true)
- start and end offsets ("offsets" : true)
- term payloads ("payloads" : true), as base64 encoded bytes
If the requested information wasn't stored in the index, it will be omitted without further warning.
See [mapping](http://www.elasticsearch.org/guide/reference/mapping/core-types/) on how to configure your index to store term vectors.
Term statistics
-------------------------
Setting "term_statistics" to "true" (default is "false") will return
- total term frequency (how often a term occurs in all documents)
- document frequency (the number of documents containing the current term)
By default these values are not returned since term statistics can have a serious performance impact.
Field statistics
-------------------------
Setting "field_statistics" to "false" (default is "true") will omit
- document count (how many documents contain this field)
- sum of document frequencies (the sum of document frequencies for all terms in this field)
- sum of total term frequencies (the sum of total term frequencies of each term in this field)
Behavior
-------------------------
The term and field statistics are not accurate. Deleted documents are not taken into account. The information is only retrieved for the shard the requested document resides in. The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
Example
-------------------------
First, we create an index that stores term vectors, payloads etc. :
curl -s -XPUT 'http://localhost:9200/twitter/' -d '{
"mappings": {
"tweet": {
"properties": {
"text": {
"type": "string",
"term_vector": "with_positions_offsets_payloads",
"store" : "yes",
"index_analyzer" : "fulltext_analyzer"
},
"fullname": {
"type": "string",
"term_vector": "with_positions_offsets_payloads",
"index_analyzer" : "fulltext_analyzer"
}
}
}
},
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
},
"analysis": {
"analyzer": {
"fulltext_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"type_as_payload"
]
}
}
}
}
}'
Second, we add some documents:
curl -XPUT 'http://localhost:9200/twitter/tweet/1?pretty=true' -d '{
"fullname" : "John Doe",
"text" : "twitter test test test "
}'
curl -XPUT 'http://localhost:9200/twitter/tweet/2?pretty=true' -d '{
"fullname" : "Jane Doe",
"text" : "Another twitter test ..."
}'
The following request returns all information and statistics for field "text" in document "1" (John Doe):
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true' -d '{
"fields" : ["text"],
"offsets" : true,
"payloads" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}'
Equivalently, all parameters can be passed as URI parameters:
curl -GET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true&fields=text&offsets=true&payloads=true&positions=true&term_statistics=true&field_statistics=true'
Response:
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_version" : 1,
"exists" : true,
"term_vectors" : {
"text" : {
"field_statistics" : {
"sum_doc_freq" : 6,
"doc_count" : 2,
"sum_ttf" : 8
},
"terms" : {
"test" : {
"doc_freq" : 2,
"ttf" : 4,
"term_freq" : 3,
"pos" : [ 1, 2, 3 ],
"start" : [ 8, 13, 18 ],
"end" : [ 12, 17, 22 ],
"payload" : [ "d29yZA==", "d29yZA==", "d29yZA==" ]
},
"twitter" : {
"doc_freq" : 2,
"ttf" : 2,
"term_freq" : 1,
"pos" : [ 0 ],
"start" : [ 0 ],
"end" : [ 7 ],
"payload" : [ "d29yZA==" ]
}
}
}
}
}
Further changes:
-------------------------
XContentBuilder
new method
public XContentBuilder field(XContentBuilderString name, int offset, int length, int... value)
to put an integer array.
IndicesAnalysisService
make token filter for saving payloads available in elasticsearch
AbstractFieldMapper/TypeParser
make term vector options string available and also fix the parsing of this string:
with_positions_payloads is actually allowed as can be seen in TermVectorsConsumerPerFields.
Closes #3114
2013-05-29 19:31:19 +02:00
|
|
|
import org.elasticsearch.rest.action.termvector.RestTermVectorAction;
|
2012-01-02 22:02:19 +02:00
|
|
|
import org.elasticsearch.rest.action.update.RestUpdateAction;
|
2010-02-17 09:28:06 +02:00
|
|
|
|
2011-02-10 17:23:49 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2010-02-17 09:28:06 +02:00
|
|
|
/**
|
2011-12-06 02:42:25 +02:00
|
|
|
*
|
2010-02-17 09:28:06 +02:00
|
|
|
*/
|
|
|
|
public class RestActionModule extends AbstractModule {
|
2011-02-10 17:23:49 +01:00
|
|
|
private List<Class<? extends BaseRestHandler>> restPluginsActions = Lists.newArrayList();
|
|
|
|
|
2011-03-29 13:50:25 +02:00
|
|
|
public RestActionModule(List<Class<? extends BaseRestHandler>> restPluginsActions) {
|
|
|
|
this.restPluginsActions = restPluginsActions;
|
2011-02-10 17:23:49 +01:00
|
|
|
}
|
2010-02-17 09:28:06 +02:00
|
|
|
|
2011-12-06 02:42:25 +02:00
|
|
|
@Override
|
|
|
|
protected void configure() {
|
2011-02-10 17:23:49 +01:00
|
|
|
for (Class<? extends BaseRestHandler> restAction : restPluginsActions) {
|
|
|
|
bind(restAction).asEagerSingleton();
|
|
|
|
}
|
|
|
|
|
2010-02-17 09:28:06 +02:00
|
|
|
bind(RestMainAction.class).asEagerSingleton();
|
|
|
|
|
|
|
|
bind(RestNodesInfoAction.class).asEagerSingleton();
|
2010-05-09 09:59:43 +03:00
|
|
|
bind(RestNodesStatsAction.class).asEagerSingleton();
|
2012-08-02 14:52:31 +03:00
|
|
|
bind(RestNodesHotThreadsAction.class).asEagerSingleton();
|
2010-03-17 00:29:36 +02:00
|
|
|
bind(RestNodesShutdownAction.class).asEagerSingleton();
|
2010-05-01 03:00:06 +03:00
|
|
|
bind(RestNodesRestartAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
bind(RestClusterStateAction.class).asEagerSingleton();
|
2010-02-24 23:16:01 +02:00
|
|
|
bind(RestClusterHealthAction.class).asEagerSingleton();
|
2011-08-20 04:00:41 +03:00
|
|
|
bind(RestClusterUpdateSettingsAction.class).asEagerSingleton();
|
|
|
|
bind(RestClusterGetSettingsAction.class).asEagerSingleton();
|
2011-10-16 19:02:32 +02:00
|
|
|
bind(RestClusterRerouteAction.class).asEagerSingleton();
|
2013-03-05 07:24:07 -05:00
|
|
|
bind(RestClusterSearchShardsAction.class).asEagerSingleton();
|
2013-07-23 15:32:56 +02:00
|
|
|
bind(RestPendingClusterTasksAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
|
2011-06-12 12:01:29 +03:00
|
|
|
bind(RestIndicesExistsAction.class).asEagerSingleton();
|
2012-09-20 18:10:56 +02:00
|
|
|
bind(RestTypesExistsAction.class).asEagerSingleton();
|
2011-08-24 11:24:52 +03:00
|
|
|
bind(RestIndicesStatsAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
bind(RestIndicesStatusAction.class).asEagerSingleton();
|
2011-06-26 00:20:50 +03:00
|
|
|
bind(RestIndicesSegmentsAction.class).asEagerSingleton();
|
2011-05-19 00:21:59 -04:00
|
|
|
bind(RestGetIndicesAliasesAction.class).asEagerSingleton();
|
2013-07-15 14:55:46 +02:00
|
|
|
bind(RestGetAliasesAction.class).asEagerSingleton();
|
2013-07-15 14:28:09 +02:00
|
|
|
bind(RestAliasesExistAction.class).asEagerSingleton();
|
2013-05-17 12:29:24 +02:00
|
|
|
bind(RestIndexDeleteAliasesAction.class).asEagerSingleton();
|
|
|
|
bind(RestIndexPutAliasAction.class).asEagerSingleton();
|
2010-03-25 02:00:53 +02:00
|
|
|
bind(RestIndicesAliasesAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
bind(RestCreateIndexAction.class).asEagerSingleton();
|
|
|
|
bind(RestDeleteIndexAction.class).asEagerSingleton();
|
2010-10-23 21:52:09 +02:00
|
|
|
bind(RestCloseIndexAction.class).asEagerSingleton();
|
|
|
|
bind(RestOpenIndexAction.class).asEagerSingleton();
|
2011-03-29 13:50:25 +02:00
|
|
|
|
2010-08-08 09:17:09 +03:00
|
|
|
bind(RestUpdateSettingsAction.class).asEagerSingleton();
|
2011-03-29 13:50:25 +02:00
|
|
|
bind(RestGetSettingsAction.class).asEagerSingleton();
|
|
|
|
|
2010-11-21 17:33:35 +02:00
|
|
|
bind(RestAnalyzeAction.class).asEagerSingleton();
|
2010-11-26 15:45:18 +02:00
|
|
|
bind(RestGetIndexTemplateAction.class).asEagerSingleton();
|
|
|
|
bind(RestPutIndexTemplateAction.class).asEagerSingleton();
|
|
|
|
bind(RestDeleteIndexTemplateAction.class).asEagerSingleton();
|
2013-08-04 13:51:34 +02:00
|
|
|
bind(RestHeadIndexTemplateAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
|
2012-05-06 18:50:35 +03:00
|
|
|
bind(RestPutWarmerAction.class).asEagerSingleton();
|
|
|
|
bind(RestDeleteWarmerAction.class).asEagerSingleton();
|
|
|
|
bind(RestGetWarmerAction.class).asEagerSingleton();
|
|
|
|
|
2010-02-21 16:49:42 +02:00
|
|
|
bind(RestPutMappingAction.class).asEagerSingleton();
|
2010-09-16 14:35:07 +02:00
|
|
|
bind(RestDeleteMappingAction.class).asEagerSingleton();
|
2010-06-17 17:56:07 +03:00
|
|
|
bind(RestGetMappingAction.class).asEagerSingleton();
|
2013-10-14 08:53:07 +02:00
|
|
|
bind(RestGetFieldMappingAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
|
|
|
|
bind(RestGatewaySnapshotAction.class).asEagerSingleton();
|
|
|
|
|
|
|
|
bind(RestRefreshAction.class).asEagerSingleton();
|
|
|
|
bind(RestFlushAction.class).asEagerSingleton();
|
|
|
|
bind(RestOptimizeAction.class).asEagerSingleton();
|
2010-04-01 12:25:51 +03:00
|
|
|
bind(RestClearIndicesCacheAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
|
|
|
|
bind(RestIndexAction.class).asEagerSingleton();
|
|
|
|
bind(RestGetAction.class).asEagerSingleton();
|
2013-05-06 12:55:32 +02:00
|
|
|
bind(RestGetSourceAction.class).asEagerSingleton();
|
2012-06-22 19:32:38 +02:00
|
|
|
bind(RestHeadAction.class).asEagerSingleton();
|
2011-06-27 22:23:49 +03:00
|
|
|
bind(RestMultiGetAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
bind(RestDeleteAction.class).asEagerSingleton();
|
|
|
|
bind(RestDeleteByQueryAction.class).asEagerSingleton();
|
2013-10-30 10:08:31 -05:00
|
|
|
bind(org.elasticsearch.rest.action.count.RestCountAction.class).asEagerSingleton();
|
# REST Suggester API
The REST Suggester API binds the 'Suggest API' to the REST Layer directly. Hence there is no need to touch the query layer for requesting suggestions.
This API extracts the Phrase Suggester API and makes 'suggestion request' top-level objects in suggestion requests. The complete API can be found in the
underlying ["Suggest Feature API"](http://www.elasticsearch.org/guide/reference/api/search/suggest.html).
# API Example
The following examples show how Suggest Actions work on the REST layer. According to this a simple request and its response will be shown.
## Suggestion Request
```json
curl -XPOST 'localhost:9200/_suggest?pretty=true' -d '{
"text" : "Xor the Got-Jewel",
"simple_phrase" : {
"phrase" : {
"analyzer" : "bigram",
"field" : "bigram",
"size" : 1,
"real_word_error_likelihood" : 0.95,
"max_errors" : 0.5,
"gram_size" : 2
}
}
}'
```
This example shows how to query a suggestion for the global text 'Xor the Got-Jewel'. A 'simple phrase' suggestion is requested and
a 'direct generator' is configured to generate the candidates.
## Suggestion Response
On success the request above will reply with a response like the following:
```json
{
"simple_phrase" : [ {
"text" : "Xor the Got-Jewel",
"offset" : 0,
"length" : 17,
"options" : [ {
"text" : "xorr the the got got jewel",
"score" : 3.5283546E-4
} ]
} ]
}
```
The 'suggest'-response contains a single 'simple phrase' which contains an 'option' in turn. This option represents a suggestion of the
queried text. It contains the corrected text and a score indicating the probability of this option to be meant.
Closes #2774
2013-03-11 17:39:18 +01:00
|
|
|
bind(RestSuggestAction.class).asEagerSingleton();
|
term vector request
================================
Returns information and statistics on terms in the fields of a particular document as stored in the index.
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true'
Tree types of values can be requested: term information, term statistics and field statistics.
By default, all term information and field statistics are returned for all fields but no term statistics.
Optionally, you can specify the fields for which the information is retrieved either with a parameter in the url
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?fields=text,...'
or adding by adding the requested fields in the request body (see example below).
Term information
-------------------------
- term frequency in the field (always returned)
- term positions ("positions" : true)
- start and end offsets ("offsets" : true)
- term payloads ("payloads" : true), as base64 encoded bytes
If the requested information wasn't stored in the index, it will be omitted without further warning.
See [mapping](http://www.elasticsearch.org/guide/reference/mapping/core-types/) on how to configure your index to store term vectors.
Term statistics
-------------------------
Setting "term_statistics" to "true" (default is "false") will return
- total term frequency (how often a term occurs in all documents)
- document frequency (the number of documents containing the current term)
By default these values are not returned since term statistics can have a serious performance impact.
Field statistics
-------------------------
Setting "field_statistics" to "false" (default is "true") will omit
- document count (how many documents contain this field)
- sum of document frequencies (the sum of document frequencies for all terms in this field)
- sum of total term frequencies (the sum of total term frequencies of each term in this field)
Behavior
-------------------------
The term and field statistics are not accurate. Deleted documents are not taken into account. The information is only retrieved for the shard the requested document resides in. The term and field statistics are therefore only useful as relative measures whereas the absolute numbers have no meaning in this context.
Example
-------------------------
First, we create an index that stores term vectors, payloads etc. :
curl -s -XPUT 'http://localhost:9200/twitter/' -d '{
"mappings": {
"tweet": {
"properties": {
"text": {
"type": "string",
"term_vector": "with_positions_offsets_payloads",
"store" : "yes",
"index_analyzer" : "fulltext_analyzer"
},
"fullname": {
"type": "string",
"term_vector": "with_positions_offsets_payloads",
"index_analyzer" : "fulltext_analyzer"
}
}
}
},
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 0
},
"analysis": {
"analyzer": {
"fulltext_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"type_as_payload"
]
}
}
}
}
}'
Second, we add some documents:
curl -XPUT 'http://localhost:9200/twitter/tweet/1?pretty=true' -d '{
"fullname" : "John Doe",
"text" : "twitter test test test "
}'
curl -XPUT 'http://localhost:9200/twitter/tweet/2?pretty=true' -d '{
"fullname" : "Jane Doe",
"text" : "Another twitter test ..."
}'
The following request returns all information and statistics for field "text" in document "1" (John Doe):
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true' -d '{
"fields" : ["text"],
"offsets" : true,
"payloads" : true,
"positions" : true,
"term_statistics" : true,
"field_statistics" : true
}'
Equivalently, all parameters can be passed as URI parameters:
curl -GET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true&fields=text&offsets=true&payloads=true&positions=true&term_statistics=true&field_statistics=true'
Response:
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_version" : 1,
"exists" : true,
"term_vectors" : {
"text" : {
"field_statistics" : {
"sum_doc_freq" : 6,
"doc_count" : 2,
"sum_ttf" : 8
},
"terms" : {
"test" : {
"doc_freq" : 2,
"ttf" : 4,
"term_freq" : 3,
"pos" : [ 1, 2, 3 ],
"start" : [ 8, 13, 18 ],
"end" : [ 12, 17, 22 ],
"payload" : [ "d29yZA==", "d29yZA==", "d29yZA==" ]
},
"twitter" : {
"doc_freq" : 2,
"ttf" : 2,
"term_freq" : 1,
"pos" : [ 0 ],
"start" : [ 0 ],
"end" : [ 7 ],
"payload" : [ "d29yZA==" ]
}
}
}
}
}
Further changes:
-------------------------
XContentBuilder
new method
public XContentBuilder field(XContentBuilderString name, int offset, int length, int... value)
to put an integer array.
IndicesAnalysisService
make token filter for saving payloads available in elasticsearch
AbstractFieldMapper/TypeParser
make term vector options string available and also fix the parsing of this string:
with_positions_payloads is actually allowed as can be seen in TermVectorsConsumerPerFields.
Closes #3114
2013-05-29 19:31:19 +02:00
|
|
|
bind(RestTermVectorAction.class).asEagerSingleton();
|
Multi term vector request
--------------------------
This feature allows to retrieve [term vectors](https://github.com/elasticsearch/elasticsearch/issues/3114) for a list of documents. The json request has exactly the same [format](https://github.com/elasticsearch/elasticsearch/issues/3484) as the ```_termvectors``` endpoint
It use it, call
```
curl -XGET 'http://localhost:9200/index/type/_mtermvectors' -d '{
"fields": [
"field1",
"field2",
...
],
"ids": [
"docId1",
"docId2",
...
],
"offsets": false|true,
"payloads": false|true,
"positions": false|true,
"term_statistics": false|true,
"field_statistics": false|true
}'
```
The return format is an array, each entry of which conatins the term vector response for one document:
```
{
"docs": [
{
"_index": "index",
"_type": "type",
"_id": "docId1",
"_version": 1,
"exists": true,
"term_vectors": {
...
}
},
{
"_index": "index",
"_type": "type",
"_id": "docId2",
"_version": 1,
"exists": true,
"term_vectors": {
...
}
}
]
}
```
Note that, like term vectors, the mult term vectors request will silenty skip over documents that have no term vectors stored in the index and will simply return an empty response in this case.
Closes #3536
2013-08-23 18:32:22 +02:00
|
|
|
bind(RestMultiTermVectorsAction.class).asEagerSingleton();
|
2010-09-15 12:22:07 +02:00
|
|
|
bind(RestBulkAction.class).asEagerSingleton();
|
2012-01-02 22:02:19 +02:00
|
|
|
bind(RestUpdateAction.class).asEagerSingleton();
|
|
|
|
bind(RestPercolateAction.class).asEagerSingleton();
|
2013-08-11 23:11:18 +02:00
|
|
|
bind(RestMultiPercolateAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
|
|
|
|
bind(RestSearchAction.class).asEagerSingleton();
|
2010-03-21 01:14:49 +02:00
|
|
|
bind(RestSearchScrollAction.class).asEagerSingleton();
|
2012-02-20 18:57:27 +02:00
|
|
|
bind(RestMultiSearchAction.class).asEagerSingleton();
|
2012-01-02 22:02:19 +02:00
|
|
|
|
2011-12-28 15:24:08 -07:00
|
|
|
bind(RestValidateQueryAction.class).asEagerSingleton();
|
2010-02-27 03:57:36 +02:00
|
|
|
|
|
|
|
bind(RestMoreLikeThisAction.class).asEagerSingleton();
|
2012-08-20 18:06:36 +02:00
|
|
|
|
|
|
|
bind(RestExplainAction.class).asEagerSingleton();
|
2013-07-02 18:00:05 -05:00
|
|
|
|
2013-10-30 10:08:31 -05:00
|
|
|
bind(RestAllocationAction.class).asEagerSingleton();
|
2013-07-02 18:00:05 -05:00
|
|
|
bind(RestShardsAction.class).asEagerSingleton();
|
2013-07-04 13:43:24 -05:00
|
|
|
bind(RestMasterAction.class).asEagerSingleton();
|
2013-07-04 15:40:09 -05:00
|
|
|
bind(RestNodesAction.class).asEagerSingleton();
|
2013-07-15 15:28:38 -05:00
|
|
|
bind(RestIndicesAction.class).asEagerSingleton();
|
2013-08-16 10:05:29 -06:00
|
|
|
// Fully qualified to prevent interference with rest.action.count.RestCountAction
|
|
|
|
bind(org.elasticsearch.rest.action.cat.RestCountAction.class).asEagerSingleton();
|
2013-10-28 13:43:02 -06:00
|
|
|
bind(RestRecoveryAction.class).asEagerSingleton();
|
2013-10-30 10:08:31 -05:00
|
|
|
bind(RestClearScrollAction.class).asEagerSingleton();
|
2010-02-17 09:28:06 +02:00
|
|
|
}
|
|
|
|
}
|