{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/36080202","id":36080202,"diff_hunk":"@@ -19,201 +19,103 @@\n \n package org.elasticsearch.index.query;\n \n-import com.google.common.collect.ImmutableMap;\n-import com.google.common.collect.Maps;\n-\n-import org.apache.lucene.analysis.Analyzer;\n-import org.apache.lucene.queryparser.classic.MapperQueryParser;\n-import org.apache.lucene.queryparser.classic.QueryParserSettings;\n-import org.apache.lucene.search.Filter;\n import org.apache.lucene.search.Query;\n-import org.apache.lucene.search.join.BitDocIdSetFilter;\n-import org.apache.lucene.search.similarities.Similarity;\n-import org.elasticsearch.Version;\n-import org.elasticsearch.cluster.metadata.IndexMetaData;\n import org.elasticsearch.common.Nullable;\n import org.elasticsearch.common.ParseField;\n import org.elasticsearch.common.ParseFieldMatcher;\n-import org.elasticsearch.common.settings.Settings;\n import org.elasticsearch.common.xcontent.XContentParser;\n import org.elasticsearch.index.Index;\n-import org.elasticsearch.index.analysis.AnalysisService;\n-import org.elasticsearch.index.fielddata.IndexFieldData;\n-import org.elasticsearch.index.mapper.*;\n-import org.elasticsearch.index.mapper.core.StringFieldMapper;\n-import org.elasticsearch.index.mapper.object.ObjectMapper;\n-import org.elasticsearch.index.query.support.NestedScope;\n-import org.elasticsearch.index.similarity.SimilarityService;\n-import org.elasticsearch.script.ScriptService;\n-import org.elasticsearch.search.fetch.innerhits.InnerHitsContext;\n-import org.elasticsearch.search.internal.SearchContext;\n-import org.elasticsearch.search.lookup.SearchLookup;\n+import org.elasticsearch.indices.query.IndicesQueriesRegistry;\n \n import java.io.IOException;\n-import java.util.*;\n \n public class QueryParseContext {\n \n     private static final ParseField CACHE = new ParseField(\"_cache\").withAllDeprecated(\"Elasticsearch makes its own caching decisions\");\n     private static final ParseField CACHE_KEY = new ParseField(\"_cache_key\").withAllDeprecated(\"Filters are always used as cache keys\");\n \n-    private static ThreadLocal<String[]> typesContext = new ThreadLocal<>();\n-\n-    public static void setTypes(String[] types) {\n-        typesContext.set(types);\n-    }\n-\n-    public static String[] getTypes() {\n-        return typesContext.get();\n-    }\n-\n-    public static String[] setTypesWithPrevious(String[] types) {\n-        String[] old = typesContext.get();\n-        setTypes(types);\n-        return old;\n-    }\n-\n-    public static void removeTypes() {\n-        typesContext.remove();\n-    }\n-\n-    private final Index index;\n-\n-    private final Version indexVersionCreated;\n-\n-    private final IndexQueryParserService indexQueryParser;\n-\n-    private final Map<String, Query> namedQueries = Maps.newHashMap();\n-\n-    private final MapperQueryParser queryParser = new MapperQueryParser(this);\n-\n     private XContentParser parser;\n-\n+    private final Index index;\n+    private boolean isFilter;\n     private ParseFieldMatcher parseFieldMatcher;\n \n-    private boolean allowUnmappedFields;\n-\n-    private boolean mapUnmappedFieldAsString;\n-\n-    private NestedScope nestedScope;\n-\n-    private boolean isFilter;\n+    private final QueryCreationContext context;\n+    private IndicesQueriesRegistry indicesQueriesRegistry;\n \n     public QueryParseContext(Index index, IndexQueryParserService indexQueryParser) {\n-        this.index = index;\n-        this.indexVersionCreated = Version.indexCreated(indexQueryParser.indexSettings());\n-        this.indexQueryParser = indexQueryParser;\n-    }\n-\n-    public void parseFieldMatcher(ParseFieldMatcher parseFieldMatcher) {\n-        this.parseFieldMatcher = parseFieldMatcher;\n+        this(new QueryCreationContext(index, indexQueryParser));\n     }\n \n-    public ParseFieldMatcher parseFieldMatcher() {\n-        return parseFieldMatcher;\n+    public QueryParseContext(QueryCreationContext context) {\n+        this.context = context;\n+        this.index = context.index();\n+        this.indicesQueriesRegistry = context.indexQueryParserService().indicesQueriesRegistry();\n     }\n \n     public void reset(XContentParser jp) {\n-        allowUnmappedFields = indexQueryParser.defaultAllowUnmappedFields();\n         this.parseFieldMatcher = ParseFieldMatcher.EMPTY;\n-        this.lookup = null;\n         this.parser = jp;\n-        this.namedQueries.clear();\n-        this.nestedScope = new NestedScope();\n-        this.isFilter = false;\n+        this.context.reset();\n     }\n \n-    public Index index() {\n-        return this.index;\n-    }\n-\n-    public void parser(XContentParser parser) {\n-        this.parser = parser;\n+    public QueryCreationContext context() {","path":"core/src/main/java/org/elasticsearch/index/query/QueryParseContext.java","position":125,"original_position":125,"commit_id":"3d2f3baea778e535210d0f75243a29692227f18d","original_commit_id":"3d2f3baea778e535210d0f75243a29692227f18d","user":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"body":"rename to `getQueryCreationContext()` ","created_at":"2015-08-03T12:30:36Z","updated_at":"2015-08-03T12:30:36Z","html_url":"https://github.com/elastic/elasticsearch/pull/12527#discussion_r36080202","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/36080202"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/12527#discussion_r36080202"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527","id":41112771,"html_url":"https://github.com/elastic/elasticsearch/pull/12527","diff_url":"https://github.com/elastic/elasticsearch/pull/12527.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/12527.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/12527","number":12527,"state":"open","locked":false,"title":"Proto: Separating QueryParseContext and QueryCreationContext","user":{"login":"cbuescher","id":10398885,"avatar_url":"https://avatars.githubusercontent.com/u/10398885?v=3","gravatar_id":"","url":"https://api.github.com/users/cbuescher","html_url":"https://github.com/cbuescher","followers_url":"https://api.github.com/users/cbuescher/followers","following_url":"https://api.github.com/users/cbuescher/following{/other_user}","gists_url":"https://api.github.com/users/cbuescher/gists{/gist_id}","starred_url":"https://api.github.com/users/cbuescher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbuescher/subscriptions","organizations_url":"https://api.github.com/users/cbuescher/orgs","repos_url":"https://api.github.com/users/cbuescher/repos","events_url":"https://api.github.com/users/cbuescher/events{/privacy}","received_events_url":"https://api.github.com/users/cbuescher/received_events","type":"User","site_admin":false},"body":"The parse() method we are currently splitting into a query parsing part (fromXContent()) and a lucene query generating part (toQuery()) in the feature refactoring branch (#10217) takes QueryParseContext as an argument. At some point we need to excute these two steps in different phases on the coordinating node and the shards. This protoype PR tries to anticipate this by introducing a new QueryCreationContext object as the argument of the query-generating methods (toQuery() and all dependent methods). \r\nAs a first step the existing QueryParseContext is renamed to QueryCreationContext, which itself acts as a wrapper around a new lightweight QueryParseContext that should only contain the functionality used during query parsing. In subsequent steps we can then try to separate the different behaviour needed in the two context objects.\r\n\r\nThis is WIP, the separation of the two context is not completely clean and local variables are not renames. Also the naming of the new context object is completely open. Would like to open this PR to get feedback and discuss. \r\n\r\nPR goes against query refactoring branch.","created_at":"2015-07-29T11:30:48Z","updated_at":"2015-08-03T12:30:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8f90781714a1b61b50d15b9e0db2b8cbb654fb5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/12527/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/3d2f3baea778e535210d0f75243a29692227f18d","head":{"label":"cbuescher:feature/query-refactoring-queryCreationContext","ref":"feature/query-refactoring-queryCreationContext","sha":"3d2f3baea778e535210d0f75243a29692227f18d","user":{"login":"cbuescher","id":10398885,"avatar_url":"https://avatars.githubusercontent.com/u/10398885?v=3","gravatar_id":"","url":"https://api.github.com/users/cbuescher","html_url":"https://github.com/cbuescher","followers_url":"https://api.github.com/users/cbuescher/followers","following_url":"https://api.github.com/users/cbuescher/following{/other_user}","gists_url":"https://api.github.com/users/cbuescher/gists{/gist_id}","starred_url":"https://api.github.com/users/cbuescher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbuescher/subscriptions","organizations_url":"https://api.github.com/users/cbuescher/orgs","repos_url":"https://api.github.com/users/cbuescher/repos","events_url":"https://api.github.com/users/cbuescher/events{/privacy}","received_events_url":"https://api.github.com/users/cbuescher/received_events","type":"User","site_admin":false},"repo":{"id":28811483,"name":"elasticsearch","full_name":"cbuescher/elasticsearch","owner":{"login":"cbuescher","id":10398885,"avatar_url":"https://avatars.githubusercontent.com/u/10398885?v=3","gravatar_id":"","url":"https://api.github.com/users/cbuescher","html_url":"https://github.com/cbuescher","followers_url":"https://api.github.com/users/cbuescher/followers","following_url":"https://api.github.com/users/cbuescher/following{/other_user}","gists_url":"https://api.github.com/users/cbuescher/gists{/gist_id}","starred_url":"https://api.github.com/users/cbuescher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbuescher/subscriptions","organizations_url":"https://api.github.com/users/cbuescher/orgs","repos_url":"https://api.github.com/users/cbuescher/repos","events_url":"https://api.github.com/users/cbuescher/events{/privacy}","received_events_url":"https://api.github.com/users/cbuescher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cbuescher/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/cbuescher/elasticsearch","forks_url":"https://api.github.com/repos/cbuescher/elasticsearch/forks","keys_url":"https://api.github.com/repos/cbuescher/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cbuescher/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cbuescher/elasticsearch/teams","hooks_url":"https://api.github.com/repos/cbuescher/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/cbuescher/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/cbuescher/elasticsearch/events","assignees_url":"https://api.github.com/repos/cbuescher/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/cbuescher/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/cbuescher/elasticsearch/tags","blobs_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cbuescher/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/cbuescher/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/cbuescher/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/cbuescher/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/cbuescher/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/cbuescher/elasticsearch/subscription","commits_url":"https://api.github.com/repos/cbuescher/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/cbuescher/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/cbuescher/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/cbuescher/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/cbuescher/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/cbuescher/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cbuescher/elasticsearch/merges","archive_url":"https://api.github.com/repos/cbuescher/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cbuescher/elasticsearch/downloads","issues_url":"https://api.github.com/repos/cbuescher/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/cbuescher/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/cbuescher/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/cbuescher/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cbuescher/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/cbuescher/elasticsearch/releases{/id}","created_at":"2015-01-05T12:21:34Z","updated_at":"2015-01-19T11:05:49Z","pushed_at":"2015-08-03T10:06:14Z","git_url":"git://github.com/cbuescher/elasticsearch.git","ssh_url":"git@github.com:cbuescher/elasticsearch.git","clone_url":"https://github.com/cbuescher/elasticsearch.git","svn_url":"https://github.com/cbuescher/elasticsearch","homepage":"http://elasticsearch.org","size":142103,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:feature/query-refactoring","ref":"feature/query-refactoring","sha":"7f28dc14eeb12585a0e8c0fcaec95e40843e444b","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-08-03T10:47:33Z","pushed_at":"2015-08-03T12:18:10Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":1916076,"stargazers_count":12190,"watchers_count":12190,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3908,"mirror_url":null,"open_issues_count":1182,"forks":3908,"open_issues":1182,"watchers":12190,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/12527"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/12527"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/12527/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/12527/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/3d2f3baea778e535210d0f75243a29692227f18d"}}}}