forked from elastic/elasticsearch
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to retrieve fields from field data
Adds a new FetchSubPhase, FieldDataFieldsFetchSubPhase, which loads the field data cache for a field and returns an array of values for the field. Also removes `doc['<field>']` and `_source.<field>` workaround no longer needed in field name resolving. Closes elastic#4492
- Loading branch information
Showing
18 changed files
with
395 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[[search-request-fielddata-fields]] | ||
=== Field Data Fields | ||
|
||
Allows to return the field data representiation of a field for each hit, for | ||
example: | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
{ | ||
"query" : { | ||
... | ||
}, | ||
"fielddata_fields" : ["test1", "test2"] | ||
} | ||
-------------------------------------------------- | ||
|
||
Field data fields can work on fields that are not stored. | ||
|
||
It's important to understand that using the `fielddata_fields` parameter will | ||
cause the terms for that field to be loaded to memory (cached), which will | ||
result in more memory consumption. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/org/elasticsearch/search/fetch/fielddata/FieldDataFieldsContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this 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.search.fetch.fielddata; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* All the required context to pull a field from the field data cache. | ||
*/ | ||
public class FieldDataFieldsContext { | ||
|
||
public static class FieldDataField { | ||
private final String name; | ||
|
||
public FieldDataField(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String name() { | ||
return name; | ||
} | ||
} | ||
|
||
private List<FieldDataField> fields = Lists.newArrayList(); | ||
|
||
public FieldDataFieldsContext() { | ||
} | ||
|
||
public void add(FieldDataField field) { | ||
this.fields.add(field); | ||
} | ||
|
||
public List<FieldDataField> fields() { | ||
return this.fields; | ||
} | ||
} |
Oops, something went wrong.