'_' search error


(Mr sun) #1

sorry for my English.
Search for ('xx_xx' or '_') by elasticsearch is not find ,why?how can i do?


(Shay Banon) #2

How do you search, and what do you index?

On Thu, Nov 4, 2010 at 6:28 AM, Mr sun xlsunchaoyx@gmail.com wrote:

sorry for my English.
Search for ('xx_xx' or '_') by elasticsearch is not find ,why?how can i do?


(Mr sun) #3

search, For example, 'aa_bb_cc'
https://github.com/aparo/pyes, I do this

q = TermQuery("name", "aa_bb_cc")
conn.search(query = q)
NOW,it's other errors. thanks for you.


(Mr sun) #4

conn = ES('127.0.0.1:9200')

conn.create_index('test-index')

mapping = {u'name': {'boost': 1.0,'index': 'analyzed','store': 'yes','type':
u'string',"term_vector" : "with_positions_offsets"},u'value': {'boost':
1.0,'index': 'analyzed','store': 'yes','type': u'string',"term_vector" :
"with_positions_offsets"}}

conn.put_mapping("test-type", {'properties':mapping}, ["test-index"])

conn.index({'name':'aa_bb','value':'123'},'test-index','test-type',1)

conn.refresh(['test-index'])

1.##################
q1 = TermQuery('name','aa_bb')
conn.search(query = q1)

result:
{u'_shards': {u'failed': 0, u'successful': 65, u'total': 65},
u'hits': {u'hits': [], u'max_score': None, u'total': 0}}

2.#######################
q2 = TermQuery('value','123')
conn.search(query = q2)
result:
{u'_shards': {u'failed': 0, u'successful': 65, u'total': 65},
u'hits': {u'hits': [{u'_id': u'1',
u'_index': u'test-index',
u'_score': 0.30685282000000003,
u'_source': {u'name': u'aa_bb', u'value': u'123'},
u'_type': u'test-type'}],
u'max_score': 0.30685282000000003,
u'total': 1}}


(Ronald Bai) #5

I test this problem:
curl -XGET http://localhost:9200/permission/permission-type/_search -d '
{ "query" : { "wildcard" : { "name" : "*" } } }
' && echo
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":12,"max_score":1.0,"hits":[{"_index":"permission","_type":"permission-type","_id":"department_set_hr","_score":1.0,
"_source" : {"codename": "department_set_hr", "name":
"\u7f16\u8f91\u90e8\u95e8"}},.......]}}

curl -XGET http://localhost:9200/permission/permission-type/_search -d '
{ "query" : { "term" : { "codename" : "department_set_hr" } } }
' && echo
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.6931472,"hits":[{"_index":"permission","_type":"permission-type","_id":"department_set_hr","_score":1.6931472,
"_source" : {"codename": "department_set_hr", "name":
"\u7f16\u8f91\u90e8\u95e8"}}]}}

It is no problem.

2010/11/5 Mr sun xlsunchaoyx@gmail.com

search, For example, 'aa_bb_cc'
https://github.com/aparo/pyes, I do this

q = TermQuery("name", "aa_bb_cc")
conn.search(query = q)
NOW,it's other errors. thanks for you.


(Alberto Paro-2) #6

If there are problems with pyes, open an issue on github with an example and I'll fix it.

thanks
Alberto

Inviato da iPhone

Il giorno 05/nov/2010, alle ore 04:57, Ronald Bai ouyanghongyu@gmail.com ha scritto:

I test this problem:
curl -XGET http://localhost:9200/permission/permission-type/_search -d '
{ "query" : { "wildcard" : { "name" : "*" } } }
' && echo
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":12,"max_score":1.0,"hits":[{"_index":"permission","_type":"permission-type","_id":"department_set_hr","_score":1.0, "_source" : {"codename": "department_set_hr", "name": "\u7f16\u8f91\u90e8\u95e8"}},.......]}}

curl -XGET http://localhost:9200/permission/permission-type/_search -d '
{ "query" : { "term" : { "codename" : "department_set_hr" } } }
' && echo
{"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.6931472,"hits":[{"_index":"permission","_type":"permission-type","_id":"department_set_hr","_score":1.6931472, "_source" : {"codename": "department_set_hr", "name": "\u7f16\u8f91\u90e8\u95e8"}}]}}

It is no problem.

2010/11/5 Mr sun xlsunchaoyx@gmail.com
search, For example, 'aa_bb_cc'
https://github.com/aparo/pyes, I do this

q = TermQuery("name", "aa_bb_cc")
conn.search(query = q)

NOW,it's other errors. thanks for you.


(Mr sun) #7

mapping = {u'name': {'type': u'string','index':'not_analyzed'}}

it's ok!


(system) #8