Nilesh
Nilesh

Reputation: 442

Search for multivalue field not working in solr

I have a multi valued field in solr which has names for user like

{
    "counsel_for_department": [
      "mr  a g  srivastava with mr xyz doe,
      " mr  johh david and mr john deo",
      " mr  n p  smith and mr  ng smith",

    ]
  },

Whenver I query like fq=counsel_for_department:a g srivastava,it does not return any results. I am using standard tokenizer for this field

field type for this field is text_general

Let me know if we need to configure different settings for multi valued field.

I am getting following json object

  {
  "responseHeader": {
    "status": 0,
    "QTime": 20,
    "params": {
      "q": "*:*",
      "indent": "true",
      "fl": "counsel_for_department",
      "fq": [
        "doc_type:source_analysis",
        "counsel_for_department:*g*c*Srivastava*"
      ],
      "rows": "100",
      "wt": "json",
      "debugQuery": "true",
      "_": "1459351342391"
    }
  },
  "response": {
    "numFound": 0,
    "start": 0,
    "docs": []
  },
  "debug": {
    "rawquerystring": "*:*",
    "querystring": "*:*",
    "parsedquery": "MatchAllDocsQuery(*:*)",
    "parsedquery_toString": "*:*",
    "explain": {},
    "QParser": "LuceneQParser",
    "filter_queries": [
      "doc_type:source_analysis",
      "counsel_for_department:*g*c*Srivastava*"
    ],
    "parsed_filter_queries": [
      "doc_type:source_analysis",
      "counsel_for_department:*g*c*srivastava*"
    ],
    "timing": {
      "time": 20,
      "prepare": {
        "time": 16,
        "query": {
          "time": 16
        },
        "facet": {
          "time": 0
        },
        "facet_module": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "expand": {
          "time": 0
        },
        "debug": {
          "time": 0
        }
      },
      "process": {
        "time": 3,
        "query": {
          "time": 3
        },
        "facet": {
          "time": 0
        },
        "facet_module": {
          "time": 0
        },
        "mlt": {
          "time": 0
        },
        "highlight": {
          "time": 0
        },
        "stats": {
          "time": 0
        },
        "expand": {
          "time": 0
        },
        "debug": {
          "time": 0
        }
      }
    }
  }
}

Thanks in advance

Upvotes: 2

Views: 561

Answers (2)

MatsLindh
MatsLindh

Reputation: 52792

Wildcard queries are not analyzed, so in most cases it's better to stay away from them, and use term matches instead. That way you'll be able to match documents regardless of the sequence of the terms as well, so "john oliver" will match "oliver john" as well, with "john oliver" boosted based on phrase matching.

To expand, the only way a wildcard match will occur is if the actual token in the underlying dataset matches - and if you have a tokenizer and filter chain present, in general, it won't as soon as you throw a space into the mix.

Drop the wildcards and use proper matching (which is what Solr really does well).

Upvotes: 1

jeorfevre
jeorfevre

Reputation: 2316

For plain text search you should go for :

fq=counsel_for_department:*a g  srivastava* 

//OR you can also use : 

fq=counsel_for_department:*a*g*srivastava*

Use like this at first. But it's a relatively expensive/slow queries in SOLR. As an improvement, if this query is very expensive(takes too much time), you should transform multivalue field in 1 consolidated field. and query that field instead of multivalue field.

Upvotes: 0

Related Questions