-1

I believe I'm having problems searching for strings that have spaces in the attribute/field names.

I successfully bulk load some people/person records using the curl command:

curl -XPOST localhost:9200/enterprise/person/_bulk --data-binary  @./JSON_DATA/people1.json

The data looks as follows:

{"index":{}}
{"Last Name": "Doe", "First Name": "Jane", "my_ID": "Person:=Jane Doe", "Age": "21"}
{"index":{}}
{"Last Name": "Smith", "First Name": "Joe", "my_ID": "Person:=Joe Smith", "Age": "23"}
{"index":{}}
{"Last Name": "Smiley", "First Name": "Bob", "my_ID": "Person:=Bob Smiley", "Age": "52"}
{"index":{}}
{"Last Name": "Doe", "First Name": "John", "my_ID": "Person:=John Doe", "Age": "32"}

I can successfully search for all document records and see that they're in the index.

However, I then try to specifically search for any person that has the string "jane" in the attribute "First Name" using the following curl command:

curl -XGET 'http://localhost:9200/enterprise/person/_search?q="First Name":jane'

This fails with the statement:

curl: (52) Empty reply from server

I believe the problem has to do with my query syntax and how I'm representing the space in the string "First Name". However, I don't know how to properly fix it.

I've also tried to search using a %20 to represent the space, using the command:

curl -XGET 'http://localhost:9200/enterprise/person/_search?q=first%20name:jane'

In this case I get a different result but it still doesn't seem to find her because she shows up in the search all results:

{"took":4,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

Any help is greatly appreciated. -- Thanks.

Community
  • 1
  • 1
Information Technology
  • 2,243
  • 3
  • 30
  • 46

1 Answers1

1

It turns out that the safer way to search is to use the query and match commands, as follows:

curl -XGET 'http://localhost:9200/enterprise/person/_search?pretty' -d '{
  "query": { "match": { "First Name": "Jane" } } 
}'

This ensures not having to deal with special characters like spaces in the URL.

Information Technology
  • 2,243
  • 3
  • 30
  • 46