Unable to get the results when searchtext containing spaces


(Aruna) #1

Hi,
I have installed elasticsearch-river-couchdb and node
elasticsearchclient. Now i am searching data in couchdb using node
elasticsearchclient. I have JSON structure like this,

{
first_name: "aruna vennapusa",
interests: [ {name: "pets", level: 5},
{topic: "es", degree: "strong"}
] ,
designation: "SE",
company: "DOM",
salary: 200000
}

and i have written code like this,
var searchText="aruna";
testSearch = function() {
var qryObj = {
"size" : 50,
"query" : {
"wildcard" : {
"_all" :searchText
}
}
};
elasticSearchClient.search("test", "",qryObj, size)
.on('data', function(data) {
console.log("Search: "+data)
assert.ok(JSON.parse(data), "testSearch failed.")
})
.exec()
}

If i search for aruna i am able to get the data. but if the part of
the searchText contains space, i am unable to get the results. suppose
searchText is "aruna vennapusa". please anyone suggest me to to get
those results.


(David Pilato) #2

The field first name is tokenized in two terms aruna and vennapusa
You can search for "aruna vennapusa" with a text query
http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
But not with wildcard as it's not analyzed.

If you really want to use wildcard you will have to change the mapping for
this field, setting it to index: not_analyzed

David.

-----Message d'origine-----
De : elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] De la part de Aruna
Envoyé : lundi 11 juin 2012 15:14
À : elasticsearch
Objet : unable to get the results when searchtext containing spaces

Hi,
I have installed elasticsearch-river-couchdb and node
elasticsearchclient. Now i am searching data in couchdb using node
elasticsearchclient. I have JSON structure like this,

{
first_name: "aruna vennapusa",
interests: [ {name: "pets", level: 5},
{topic: "es", degree: "strong"}
] ,
designation: "SE",
company: "DOM",
salary: 200000
}

and i have written code like this,
var searchText="aruna";
testSearch = function() {
var qryObj = {
"size" : 50,
"query" : {
"wildcard" : {
"_all" :searchText
}
}
};
elasticSearchClient.search("test", "",qryObj, size)
.on('data', function(data) {
console.log("Search: "+data)
assert.ok(JSON.parse(data), "testSearch failed.")
})
.exec()
}

If i search for aruna i am able to get the data. but if the part of the
searchText contains space, i am unable to get the results. suppose
searchText is "aruna vennapusa". please anyone suggest me to to get
those results.


(Aruna) #3

Thanks David. I tried with text query now its working

On Tuesday, June 12, 2012 2:02:56 AM UTC+5:30, David Pilato wrote:

The field first name is tokenized in two terms aruna and vennapusa
You can search for "aruna vennapusa" with a text query
http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html
But not with wildcard as it's not analyzed.

If you really want to use wildcard you will have to change the mapping for
this field, setting it to index: not_analyzed

David.

-----Message d'origine-----
De : elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] De la part de Aruna
Envoyé : lundi 11 juin 2012 15:14
À : elasticsearch
Objet : unable to get the results when searchtext containing spaces

Hi,
I have installed elasticsearch-river-couchdb and node
elasticsearchclient. Now i am searching data in couchdb using node
elasticsearchclient. I have JSON structure like this,

{
first_name: "aruna vennapusa",
interests: [ {name: "pets", level: 5},
{topic: "es", degree: "strong"}
] ,
designation: "SE",
company: "DOM",
salary: 200000
}

and i have written code like this,
var searchText="aruna";
testSearch = function() {
var qryObj = {
"size" : 50,
"query" : {
"wildcard" : {
"_all" :searchText
}
}
};
elasticSearchClient.search("test", "",qryObj, size)
.on('data', function(data) {
console.log("Search: "+data)
assert.ok(JSON.parse(data), "testSearch failed.")
})
.exec()
}

If i search for aruna i am able to get the data. but if the part of the
searchText contains space, i am unable to get the results. suppose
searchText is "aruna vennapusa". please anyone suggest me to to get
those results.


(system) #4