@@ -578,6 +578,7 @@ final SearchContext createContext(ShardSearchRequest request, @Nullable Engine.S
578
578
try (XContentParser parser = XContentFactory .xContent (run ).createParser (run )) {
579
579
QueryParseContext queryParseContext = new QueryParseContext (indexService .queryParserService ().indicesQueriesRegistry ());
580
580
queryParseContext .reset (parser );
581
+ queryParseContext .parseFieldMatcher (parseFieldMatcher );
581
582
parseSource (context , SearchSourceBuilder .parseSearchSource (parser , queryParseContext ));
582
583
}
583
584
}
@@ -673,8 +674,8 @@ private void processFailure(SearchContext context, Throwable t) {
673
674
private void parseSource (SearchContext context , SearchSourceBuilder source ) throws SearchParseException {
674
675
// nothing to parse...
675
676
if (source == null ) {
676
- return ;
677
- }
677
+ return ;
678
+ }
678
679
679
680
context .from (source .from ());
680
681
context .size (source .size ());
@@ -686,10 +687,10 @@ private void parseSource(SearchContext context, SearchSourceBuilder source) thro
686
687
}
687
688
}
688
689
if (source .query () != null ) {
689
- context .parsedQuery (context .queryParserService ().parse (source .query ()));
690
+ context .parsedQuery (context .queryParserService ().toQuery (source .query ()));
690
691
}
691
692
if (source .postFilter () != null ) {
692
- context .parsedPostFilter (context .queryParserService ().parse (source .postFilter ()));
693
+ context .parsedPostFilter (context .queryParserService ().toQuery (source .postFilter ()));
693
694
}
694
695
if (source .sorts () != null ) {
695
696
XContentParser completeSortParser = null ;
@@ -775,15 +776,15 @@ private void parseSource(SearchContext context, SearchSourceBuilder source) thro
775
776
}
776
777
if (source .rescores () != null ) {
777
778
XContentParser completeRescoreParser = null ;
778
- try {
779
+ try {
779
780
XContentBuilder completeRescoreBuilder = XContentFactory .jsonBuilder ();
780
781
completeRescoreBuilder .startObject ();
781
782
completeRescoreBuilder .startArray ("rescore" );
782
783
for (BytesReference rescore : source .rescores ()) {
783
784
XContentParser parser = XContentFactory .xContent (rescore ).createParser (rescore );
784
785
parser .nextToken ();
785
786
completeRescoreBuilder .copyCurrentStructure (parser );
786
- }
787
+ }
787
788
completeRescoreBuilder .endArray ();
788
789
completeRescoreBuilder .endObject ();
789
790
BytesReference completeRescoreBytes = completeRescoreBuilder .bytes ();
@@ -794,31 +795,31 @@ private void parseSource(SearchContext context, SearchSourceBuilder source) thro
794
795
this .elementParsers .get ("rescore" ).parse (completeRescoreParser , context );
795
796
} catch (Exception e ) {
796
797
String sSource = "_na_" ;
797
- try {
798
+ try {
798
799
sSource = source .toString ();
799
800
} catch (Throwable e1 ) {
800
801
// ignore
801
802
}
802
803
XContentLocation location = completeRescoreParser != null ? completeRescoreParser .getTokenLocation () : null ;
803
804
throw new SearchParseException (context , "failed to parse rescore source [" + sSource + "]" , location , e );
804
805
}
805
- }
806
+ }
806
807
if (source .fields () != null ) {
807
808
context .fieldNames ().addAll (source .fields ());
808
- }
809
+ }
809
810
if (source .explain () != null ) {
810
811
context .explain (source .explain ());
811
- }
812
+ }
812
813
if (source .fetchSource () != null ) {
813
814
context .fetchSourceContext (source .fetchSource ());
814
- }
815
+ }
815
816
if (source .fieldDataFields () != null ) {
816
817
FieldDataFieldsContext fieldDataFieldsContext = context .getFetchSubPhaseContext (FieldDataFieldsFetchSubPhase .CONTEXT_FACTORY );
817
818
for (String field : source .fieldDataFields ()) {
818
819
fieldDataFieldsContext .add (new FieldDataField (field ));
819
820
}
820
821
fieldDataFieldsContext .setHitExecutionNeeded (true );
821
- }
822
+ }
822
823
if (source .highlighter () != null ) {
823
824
XContentParser highlighterParser = null ;
824
825
try {
@@ -830,10 +831,10 @@ private void parseSource(SearchContext context, SearchSourceBuilder source) thro
830
831
sSource = source .toString ();
831
832
} catch (Throwable e1 ) {
832
833
// ignore
833
- }
834
+ }
834
835
XContentLocation location = highlighterParser != null ? highlighterParser .getTokenLocation () : null ;
835
836
throw new SearchParseException (context , "failed to parse suggest source [" + sSource + "]" , location , e );
836
- }
837
+ }
837
838
}
838
839
if (source .innerHits () != null ) {
839
840
XContentParser innerHitsParser = null ;
@@ -843,7 +844,7 @@ private void parseSource(SearchContext context, SearchSourceBuilder source) thro
843
844
this .elementParsers .get ("inner_hits" ).parse (innerHitsParser , context );
844
845
} catch (Exception e ) {
845
846
String sSource = "_na_" ;
846
- try {
847
+ try {
847
848
sSource = source .toString ();
848
849
} catch (Throwable e1 ) {
849
850
// ignore
@@ -857,40 +858,40 @@ private void parseSource(SearchContext context, SearchSourceBuilder source) thro
857
858
SearchScript searchScript = context .scriptService ().search (context .lookup (), field .script (), ScriptContext .Standard .SEARCH );
858
859
context .scriptFields ().add (new ScriptField (field .fieldName (), searchScript , field .ignoreFailure ()));
859
860
}
860
- }
861
+ }
861
862
if (source .ext () != null ) {
862
863
XContentParser extParser = null ;
863
864
try {
864
865
extParser = XContentFactory .xContent (source .ext ()).createParser (source .ext ());
865
866
XContentParser .Token token = extParser .nextToken ();
866
867
String currentFieldName = null ;
867
868
while ((token = extParser .nextToken ()) != XContentParser .Token .END_OBJECT ) {
868
- if (token == XContentParser .Token .FIELD_NAME ) {
869
+ if (token == XContentParser .Token .FIELD_NAME ) {
869
870
currentFieldName = extParser .currentName ();
870
- } else {
871
+ } else {
871
872
SearchParseElement parseElement = this .elementParsers .get (currentFieldName );
872
873
if (parseElement == null ) {
873
874
throw new SearchParseException (context , "Unknown element [" + currentFieldName + "] in [ext]" ,
874
875
extParser .getTokenLocation ());
875
- } else {
876
+ } else {
876
877
parseElement .parse (extParser , context );
878
+ }
877
879
}
878
880
}
879
- }
880
881
} catch (Exception e ) {
881
- String sSource = "_na_" ;
882
- try {
882
+ String sSource = "_na_" ;
883
+ try {
883
884
sSource = source .toString ();
884
- } catch (Throwable e1 ) {
885
- // ignore
886
- }
885
+ } catch (Throwable e1 ) {
886
+ // ignore
887
+ }
887
888
XContentLocation location = extParser != null ? extParser .getTokenLocation () : null ;
888
889
throw new SearchParseException (context , "failed to parse ext source [" + sSource + "]" , location , e );
889
890
}
890
891
}
891
892
if (source .version () != null ) {
892
893
context .version (source .version ());
893
- }
894
+ }
894
895
if (source .stats () != null ) {
895
896
context .groupStats (source .stats ());
896
897
}
@@ -1187,9 +1188,12 @@ public void run() {
1187
1188
try {
1188
1189
long now = System .nanoTime ();
1189
1190
final IndexService indexService = indicesService .indexServiceSafe (indexShard .shardId ().index ().name ());
1191
+ QueryParseContext queryParseContext = new QueryParseContext (indexService .queryParserService ().indicesQueriesRegistry ());
1192
+ // NOCOMMIT get a parseFieldMatcher from somewhere and set it on the queryParseContext
1193
+ queryParseContext .parseFieldMatcher (indexService .queryParserService ().parseFieldMatcher ());
1190
1194
ShardSearchRequest request = new ShardSearchLocalRequest (indexShard .shardId (), indexMetaData
1191
1195
.getNumberOfShards (),
1192
- SearchType .QUERY_THEN_FETCH , entry .source ().build (new QueryParseContext ( indexService . queryParserService (). indicesQueriesRegistry ()) ), entry .types (), entry .requestCache ());
1196
+ SearchType .QUERY_THEN_FETCH , entry .source ().build (queryParseContext ), entry .types (), entry .requestCache ());
1193
1197
context = createContext (request , warmerContext .searcher ());
1194
1198
// if we use sort, we need to do query to sort on
1195
1199
// it and load relevant field data
0 commit comments