skip to Main Content

When using Apache Solr’s browser search tool (on localhost), when I query *:* (return all), the GET request returns results in the following format:

  "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":12,
    "params":{
      "q":"*:*",
      "_":"1562080387377"}},
  "response":{"numFound":164,"start":0,"maxScore":1.0,"docs":[
      {
        "id":"1",
        "name":["Maria Atkinson"],
        "email":["[email protected]"],
        "phone_number":["(408)500-6026x750"],
        "password":["password"],
        "_version_":1637959617282572288},

where all the values are in square brackets.

This is a problem because I cannot GET results based on a query name, e.g. query
select?q=Maria returns nothing.

I did a POST request of the JSON file with the following command in Terminal:
bin/post -c techproducts /Users/**/Desktop/**/upload.json

My 2 questions are:

  1. What causes this square brackets behaviour?

  2. How can I query values which are enclosed in square brackets?

NOTE

In my JSON file upload, the values are not enclosed in square brackets, in the following format:

[{"id": 1, "name": "Maria Atkinson", "email": "[email protected]", "phone_number": "(408)500-6026x750", "password": "password"}, ...

2

Answers


  1. Chosen as BEST ANSWER

    Complementing the answers from Abhijit and MatsLindh, the default field for Solr is text, as defined in the Solr docs. As I didn't define a field, it defaulted to text.

    However, there is no field called text in my indexed documents, so nothing was returned.


  2. Check your schema.xml. The fields must be having multivalued as true. Change the same to false.
    Once you change the multiValued=false in the schema.xml for all your fields.
    Re index the data again.

    MultiValued defined in the schema whether the field is allowed to have more than one value. For instance: if I have a fieldType called ID which is multiValued=true indexing a document such as this: doc { id : [ 1, 2] ... }.

    Mark the fields to multiValued=false. Re index the data.

    Your search problem will get solved.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search