You are searching in hostname field not in _all. I think that's your problem here.
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 19 août 2014 à 19:53:53, Luc Evers (lucevers@gmail.com) a écrit:
David,
I have a very simple example:
- Below the data file "configs.json"
{"hostname":["My-Name"]}
- the mapping file: "_configs.json"
{
mappings: {
"mytest": {
"_all": { "analyzer": "whitespace" }
}
}
}
Thats All
Index the 'configs.json' with the mapping '_configs.json'
3) Send a search request:
Sense example
POST /whitespace/mytest/_search
{
"query": {
"filtered": {
"filter": {
"term": { "hostname": "My-Name" }
}
}
}
}
This example shall fail if the analyser is "whitespace".
If you don't analyse ("not_analyzed") the example shall work.
Because the whitespace analyser don't split the string "My-Name", the test should work!
Rem
The index name "whitespace" is only done for remembering which test is which index.
Luc.
On Tue, Aug 19, 2014 at 3:22 PM, David Pilato david@pilato.fr wrote:
I have no idea without understanding exactly what you are doing.
So a SENSE recreation would help a lot.
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 19 août 2014 à 13:53:16, Luc Evers (lucevers@gmail.com) a écrit:
David,
In my case: "My-Name" why a term filter didn't work on a whitespace filter?
Luc.
On Tue, Aug 19, 2014 at 12:28 PM, David Pilato david@pilato.fr wrote:
The Term filter only works on "Not Analysed" fields!
Is this right?
Not exactly.
Term filter is not analyzed. It means that it's compared as is to what you have in the inverted index.
So, for example, if you have indexed in the inverted index "A-B-C", searching with a Term Filter for "a-b-c" won't work.
"a" won't work as well.
May be you could create a full SENSE recreation which shows your problem so we can replay it and help you?
See Elasticsearch Platform — Find real-time answers at scale | Elastic
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 19 août 2014 à 10:28:15, Luc Evers (lucevers@gmail.com) a écrit:
David,
I made a small example to show you the problem and solution:
- Index name: whitespace
- type: mytest
Mapping:
{
mappings: {
"mytest": {
"_all": { "analyzer": "whitespace" }
}
}
}
Data
{"hostname":["My-Name"]}
Indexing : oke
First Test: Is the analyzer = whitespace oke?
curl -XGET 'http://localhost:9200/whitespace/mytest/_search?q="My"&pretty'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
}
Result: OKE
Second Test: Ask complete name
curl -XGET 'http://localhost:9200/whitespace/mytest/_search?q="My-Name"&pretty'
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.30685282,
"hits" : [ {
"_index" : "whitespace",
"_type" : "mytest",
"_id" : "2",
"_score" : 0.30685282,
"_source":{"hostname":"My-Name"}
} ]
}
}
Result: OKE
Now my problem:
curl -XPOST "http://localhost:9200/whitespace/mytest/_search" -d'
{
"query": {
"filtered": {
"filter": {
"term": { "hostname": "My-Name" }
}
}
}
}'
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":}}
Because the document was indexed with the whitespace analyzer, he should find "My-Name".
Check Analyzer: OKE
curl -XGET 'localhost:9200/_analyze?analyzer=whitespace&pretty&format=text' -d 'My-Name'
{
"tokens" : [ {
"token" : "My-Name",
"start_offset" : 0,
"end_offset" : 7,
"type" : "word",
"position" : 1
} ]
}
Test3: not_analysed Index mapping:
{
mappings: {
"mytest": {
"properties": {
"hostname": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
Then:
curl -XPOST "http://localhost:9200/whitespace/mytest/_search?pretty" -d'
{
"query": {
"filtered": {
"filter": {
"term": { "hostname": "My-Name" }
}
}
}
}'
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "whitespace",
"_type" : "mytest",
"_id" : "2",
"_score" : 1.0,
"_source":{"hostname":"My-Name"}
} ]
}
}
Result: OKE
Conlusion:
The Term filter only works on "Not Analysed" fields!
Is this right?
Rem:
No errors in de log files.
Luc.
On Mon, Aug 18, 2014 at 3:42 PM, David Pilato david@pilato.fr wrote:
I think could help you: Elasticsearch Platform — Find real-time answers at scale | Elastic
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 18 août 2014 à 15:39:36, Luc Evers (lucevers@gmail.com) a écrit:
David hi,
How can I configure the mapping so that the default analyzer will be the "whitespace" one?
On Wed, Aug 13, 2014 at 2:46 PM, David Pilato david@pilato.fr wrote:
Having no answer is not good. I think something goes wrong here. May be you should see something in logs.
That said, if you don't want to break your string as tokens at index time, you could set index:not_analyzed for fields you don't want to analyze.
But, you should read this part of the book: Elasticsearch Platform — Find real-time answers at scale | Elastic
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 13 août 2014 à 14:39:20, Luc Evers (lucevers@gmail.com) a écrit:
I like to use elasticsearch as Nosql database + search engine for data coming from text files (router configs) and databases .
First I moved a routerconfig to a json file which I indexed .
Mapping:
{
"configs" : {
"mappings" : {
"test" : {
"properties" : {
"ConfLength" : {
"type" : "string"
},
"NVRAM" : {
"type" : "string"
},
"aaa" : {
"type" : "string"
},
"enable" : {
"type" : "string"
},
"hostname" : {
"type" : "string"
},
"lastChange" : {
"type" : "string"
},
"logging" : {
"type" : "string"
},
"model" : {
"type" : "string"
},
"policy-map" : {
"type" : "string"
}
}
}
}
}
}
Document:
{
"_index" : "configs",
"_type" : "test",
"_id" : "7",
"_score" : 1,
"_source" : {
"hostname" : [
"hostname test-1234"
]
}
},
Example of a simple search: search a hostname.
If I start a query:
curl -XGET 'http://127.0.0.1:9200/configs/_search?q="hostname test-1234"'
curl: (52) Empty reply from server
No respone
If I start a second query without hostname if got an answer:
curl -XGET 'http://127.0.0.1:9200/configs/_search?q="test-1234"'
OKE
Analyser: standard
Why a search instruction can find "test-1234" but not "hostname test-1234" ?
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/xOrC6RMG_nw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53eb5e1b.3804823e.18f0%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAA0yNqLNnQK0%2BtJgRkOqwgJawqngMjmWJfXDgijpcuEbQYbyZw%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/xOrC6RMG_nw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53f202c7.2eb141f2.132%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAA0yNqJfm0w6vqmFHEgVVDHjJqtnT1yH8%2BWh2WGv3AYXcpBfCg%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/xOrC6RMG_nw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53f326d2.4e6afb66.132%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAA0yNqLF%2B%3DWGuutmZ%2BS1C09uPhC%3D%2Bf_adAKJ5YcXQTTSZD_51w%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/xOrC6RMG_nw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53f34fab.257130a3.132%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAA0yNqJp1B0fGvQgJJKkx_1%3DMmDWH_ALt36B6JSRaNejhRMUag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.53f3a10e.1d4ed43b.132%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.