Skip to content

Commit

Permalink
added URI Search Command
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunihiko Kido committed Mar 25, 2015
1 parent 54edd8b commit 4a4c898
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
{"command": "elasticsearch_delete_alias", "caption": "Elasticsearch: Delete Alias"},
{"command": "elasticsearch_get_alias", "caption": "Elasticsearch: Get Alias"},

{"command": "elasticsearch_search", "caption": "Elasticsearch: Search"},
{"command": "elasticsearch_search", "caption": "Elasticsearch: Search (Request Body Search)"},
{"command": "elasticsearch_uri_search", "caption": "Elasticsearch: Search (URI Search)"},
{"command": "elasticsearch_benchmark", "caption": "Elasticsearch: Benchmark"},
{"command": "elasticsearch_delete_percolator", "caption": "Elasticsearch: UN-Register Query (Percolator)"},
{"command": "elasticsearch_explain_document", "caption": "Elasticsearch: Explain Document"},
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ Elasticsearch: Analyze | POST | ``/index/_analyz
Elasticsearch: Benchmark | PUT | ``/_bench``
Elasticsearch: Explain Document | POST | ``/index/type/id/_explain``
Elasticsearch: Register Query (Percolator) | PUT | ``/index/.percolator/id``
Elasticsearch: Search Request | POST | ``/index/type/_search``
Elasticsearch: Search (Request Body Search) | POST | ``/index/type/_search``
Elasticsearch: Search (URI Search) | GET | ``/index/type/_search``
Elasticsearch: Show Registered Query (Percolator) | POST | ``/index/type/_percolate``
Elasticsearch: UN-Register Query (Percolator) | DELETE | ``/index/.percolator/id``

Expand Down
17 changes: 16 additions & 1 deletion elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ def get_analyzer(self, callback):
def get_warmer(self, callback):
self.show_input_panel('Warmer Name: ', '', callback)

def get_query(self, callback):
self.show_input_panel('Query: ', '', callback)

def update_server_settings(self, name, value):
servers = self.servers
servers[self.active_server][name] = value
Expand Down Expand Up @@ -313,7 +316,7 @@ def show_active_server_settings(self):
enabled_delete_warmer=self.enabled_delete_warmer(quiet=True),
enabled_add_alias=self.enabled_add_alias(quiet=True),
enabled_delete_alias=self.enabled_delete_alias(quiet=True),
enabled_update_index=self.enabled_update_index(quiet=True)
enabled_update_document=self.enabled_update_document(quiet=True)
)
)

Expand Down Expand Up @@ -694,6 +697,18 @@ def on_done(self, index):
self.request_post(path, body=body, params=params)


class ElasticsearchUriSearchCommand(ReusltJsonCommand):

def run(self):
self.get_query(self.on_done)

def on_done(self, query):
path = make_path(self.index, self.doc_type, '_search')
params = DEFAULT_PARAMS
params.update(dict(q=query))
self.request_get(path, params=params)


class ElasticsearchBenchmarkCommand(ReusltJsonCommand):

def run(self):
Expand Down

0 comments on commit 4a4c898

Please sign in to comment.