Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e39d396
Store offsets in index prefix fields when stored in the parent field
romseygeek Mar 14, 2018
e931107
Merge branch 'master' into index-phrases
romseygeek Apr 12, 2018
3719e30
Merge branch 'master' into index-phrases
romseygeek Apr 24, 2018
4cea300
Upgrade to lucene 7.4.0 snapshot
romseygeek Apr 24, 2018
efd612a
Merge branch 'master' into index-phrases
romseygeek May 2, 2018
b591fc4
Add the ability to index two-term shingles for faster phrase queries
romseygeek May 8, 2018
aca2b7e
docs
romseygeek May 8, 2018
910f0c1
Merge branch 'master' into index-phrases
romseygeek May 8, 2018
e0fe29d
Placate checkstyle
romseygeek May 8, 2018
c156cbd
changelog
romseygeek May 8, 2018
007ee3d
Merge branch 'master' into index-phrases
romseygeek May 18, 2018
66b1e48
MappedFieldType.matchQuery -> .analyzePhrase
romseygeek May 22, 2018
4d6cb66
Merge remote-tracking branch 'origin/master' into index-phrases
romseygeek May 22, 2018
9eb8a6d
iter
romseygeek May 24, 2018
69cf210
Merge remote-tracking branch 'origin/master' into index-phrases
romseygeek May 24, 2018
0deebb6
iter
romseygeek May 24, 2018
6cfa4b1
iter
romseygeek May 29, 2018
6208c31
Merge branch 'master' into index-phrases
romseygeek May 29, 2018
1d7852e
Check for positions
romseygeek May 29, 2018
289186e
Merge branch 'master' into index-phrases
romseygeek May 30, 2018
518e280
Merge branch 'master' into index-phrases
romseygeek May 30, 2018
8dd5cd5
index_phrases isn't an updateable setting
romseygeek May 30, 2018
dab97ad
Merge remote-tracking branch 'origin/master' into index-phrases
romseygeek Jun 1, 2018
b2e732a
Merge remote-tracking branch 'origin/master' into index-phrases
romseygeek Jun 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/reference/mapping/types/text.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ The following parameters are accepted by `text` fields:
the expense of a larger index. Accepts an
<<index-prefix-config,`index-prefix configuration block`>>

<<index-phrases,`index_phrases`>>::

If enabled, two-term word combinations ('shingles') are indexed into a separate
field. This allows exact phrase queries to run more efficiently, at the expense
of a larger index. Note that this works best when stopwords are not removed,
as phrases containing stopwords will not use the subsidiary field and will fall
back to a standard phrase query. Accepts `true` or `false` (default).

<<norms,`norms`>>::

Whether field-length should be taken into account when scoring queries.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
"search with indexed phrases":
- skip:
version: " - 6.99.99"
reason: index_phrase is only available as of 7.0.0
- do:
indices.create:
index: test
body:
mappings:
test:
properties:
text:
type: text
index_phrases: true

- do:
index:
index: test
type: test
id: 1
body: { text: "peter piper picked a peck of pickled peppers" }

- do:
indices.refresh:
index: [test]

- do:
search:
index: test
body:
query:
match_phrase:
text:
query: "peter piper"

- match: {hits.total: 1}

- do:
search:
index: test
q: '"peter piper"~1'
df: text

- match: {hits.total: 1}

- do:
search:
index: test
body:
query:
match_phrase:
text: "peter piper picked"

- match: {hits.total: 1}

- do:
search:
index: test
body:
query:
match_phrase:
text: "piper"

- match: {hits.total: 1}


Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.elasticsearch.index.mapper;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.IndexOptions;
import org.apache.lucene.index.IndexReader;
Expand All @@ -43,6 +44,7 @@
import org.elasticsearch.index.query.QueryRewriteContext;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.index.query.QueryShardException;
import org.elasticsearch.index.search.MatchQuery;
import org.elasticsearch.index.similarity.SimilarityProvider;
import org.elasticsearch.search.DocValueFormat;
import org.joda.time.DateTimeZone;
Expand Down Expand Up @@ -353,6 +355,14 @@ public Query regexpQuery(String value, int flags, int maxDeterminizedStates, @Nu

public abstract Query existsQuery(QueryShardContext context);

public Query phraseQuery(String field, TokenStream stream, int slop, boolean enablePositionIncrements) throws IOException {
throw new IllegalArgumentException("Can only use phrase queries on text fields - not on [" + name + "] which is of type [" + typeName() + "]");
}

public Query multiPhraseQuery(String field, TokenStream stream, int slop, boolean enablePositionIncrements) throws IOException {
throw new IllegalArgumentException("Can only use phrase queries on text fields - not on [" + name + "] which is of type [" + typeName() + "]");
}

/**
* An enum used to describe the relation between the range of terms in a
* shard when compared with a query range
Expand Down
Loading