I am trying to get all id's for a type, but I am pulling my hair out.
Please see my attacment.
HERE IS THE cURL call :
curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json'
-d'{ "query": { "wildcard" : { "id" : "Account[enter image description here][1]*" } }}'
cURL call with no results
I would guess there is an issue with the way your id-field is analyzed. You can retrieve the mapping by using the _mapping endpoint (described in the docs). Your id field should be analyzed as a string (with break characters, tokenizers and all) for the wildcard query to work. If it is not analyzed, as you might expect for an id-field, the wildcard query will not work. Then you would need to change the mapping and reindex your data to make it work.
Related
I'm trying to perform multiple concurrent search requests using Elasticsearch (version 6). Here is my queries file:
{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "school"}}}
{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "car"}}}
{"index" : "web"}
{"max_concurrent_searches": 64, "query": {"match": {"content": "cat"}}}
Here is the command I use to issue the bulk request:
curl -H "Content-Type: application/x-ndjson" -XGET ''$url'/_msearch'
--data-binary "#$file"; echo
However, I get the following error indicating my wrong usage of max_concurrent_searches parameter.
{"error":{"root_cause":[{"type":"parsing_exception","reason":"Unknown key for a VALUE_NUMBER in [max_concurrent_searches].","line":1,"col":29}],"type":"parsing_exception","reason":"Unknown key for a VALUE_NUMBER in [max_concurrent_searches].","line":1,"col":29},"status":400}
If I removed "max_concurrent_searches": 64, from the queries file above, everything works just perfect.
I want to know how can I use/set the max_concurrent_searches parameter, I couldn't find useful information in Elasticsearch documentation about this except the following:
The msearch’s max_concurrent_searches request parameter can be used to
control the maximum number of concurrent searches the multi search api
will execute. This default is based on the number of data nodes and
the default search thread pool size.
You should add it to the request itself:
Sample request: GET indexName/type/_msearch?max_concurrent_searches=1100
(where indexName and type is optional)
For you its should be like:
curl -H "Content-Type: application/x-ndjson" -XGET ''$url'/_msearch**?
max_concurrent_searches=1100**'
--data-binary "#$file"; echo
You can execute above using postman also. Just change the content-type as application/x-ndjson and dont forget to add a new line character in the end. This will give you the same error and you can correct it easily by different combinations. MultiSearch is an important feature.
I am able to search normal query . Contains fields value or sorting from elasticsearch uri search but unable to run the term aggregation queries from uri search.
How i can do this?
Term aggregation query is :
curl -u elastic -XGET '127.0.0.1:9200/indexname/typename/_search?pretty' -d'{"size": 0,"aggs": {"group_by_field": {"terms": {"field": "txt_field_name","size": 10},"aggs": {"maxDate": {"max":{"field": "dat_field_name"}}}}}}'
Can we do term aggregation queries from URI Search?
What if you have your URI query as such:
curl -u elastic -XGET 'localhost:9200/indexname/typename/_search?source={"aggs":{"maxDate":{"terms":{"field":"dat_field_name"}}}}'
I'm using Meteor (so Javascript, Node, NPM, etc) and would like to provide a simple text input for users to search via Elasticsearch. I would like to be able to use modifiers on the text like + and "" and search for a specific field. I'm looking for something that can convert a plain text input into Elasticsearch Query DSL.
These would be some example queries:
This query would mean that the keyword "tatooine" must exist:
stormtrooper +tatooine
This would mean that "death star" should be one keyword:
stormtrooper "death star"
This would search for the keyword "bloopers" only in the category field:
stormtrooper category=bloopers
Is there a library that can do this? Can a generic solution exist or is this why I can't find any existing answers to this?
simple_query_string would support your query syntax out of the box, except for category=bloopers which should be category:bloopers instead, but otherwise it should work:
curl -XPOST localhost:9200/your_index/_search -d '{
"query": {
"simple_query_string": {
"query": "stormtrooper category:bloopers"
}
}
}'
curl -XPOST localhost:9200/your_index/_search -d '{
"query": {
"simple_query_string": {
"query": "stormtrooper +tatooine"
}
}
}'
You can also send the query in the query string directly like this:
curl -XPOST localhost:9200/your_index/_search?q=stormtrooper%20%22death%20star%22"
I have filter which replace characters
char_filter:
lt_characters:
type: mapping
mappings: ["a=>bbbbbb", "c=>tttttt", "ddddddd=>k" ]
I'm add this filter to index, now how to check does this filter work, where I can found indexed data ?
I mean exactly view replacments.
To see what tokens are created with your char_filter you can use the Analyze API.
curl -XGET 'localhost:9200/_analyze?char_filters=lt_characters' -d 'this is a test'
I am fairly new to ElasticSearch and have a question on stop words. I have an index that contains state names for the USA....ex: New York/NY, California/CA,Oregon/OR. I believe Oregon's abbreviation, 'OR' is a stop word, so when I insert the state data into the index, I cannot search on 'OR'. Is there a way I can set up custom stopwords for this or am I doing something wrong?
Here is how I am building the index:
curl -XPUT http://localhost:9200/test/state/1 -d '{"stateName": ["California","CA"]}'
curl -XPUT http://localhost:9200/test/state/2 -d '{"stateName": ["New York","NY"]}'
curl -XPUT http://localhost:9200/test/state/3 -d '{"stateName": ["Oregon","OR"]}'
A search for 'NY', works fine. Ex:
curl -XGET 'http://localhost:9200/test/state/_search?pretty=1' -d '
{
"query" : {
"match" : {
"stateName" : "NY"
}
}
}'
But a search for 'OR', returns zero hits:
curl -XGET 'http://localhost:9200/test/state/_search?pretty=1' -d '
{
"query" : {
"match" : {
"stateName" : "OR"
}
}
}'
I believe this search returns no results because OR is stop word, but I don't know how to work around this. Thanks for you help.
You can (and definitely should) control the way you index data by modifying your mapping according to your data and the way you want to search against it.
In your case I would disable stopwords for that specific field rather than modifying the stopword list, but you could do the latter too if you wish to. The point is that you're using the default mapping which is great to start with, but as you can see you need to tweak it depending on your needs.
For each field, you can specify what analyzer to use. An analyzer defines the way you split your text into tokens (tokenizer) that will be indexed and also additional changes you can make to each token (even remove or add new ones) using token filters.
You can specify your mapping either while creating your index or update it afterwards using the put mapping api (as long as the changes you make are backwards compatible).