1

I'm trying to understand how to make a userInput() work, with the minimum of settings. I could not retrieve results for keyword "product", even with "product 1" in some document titles. I simplified the query and settings to the bare minimum. Filters and aggregations work fine.

The field definition, without any ranking, fieldset, ...:

field wpsolr_title type string {
  indexing: summary | index
}

The field content in a document: enter image description here

The query:

{"userQuery":"product","yql":"select * from wpsolr1 where (userInput(@userQuery))"}
WPSOLR
  • 50
  • 1
  • 7

1 Answers1

1

Since you're not specifying the index, terms in the user query will by default search default so the parsed query here becomes

select * from wpsolr1 where weakAnd(default contains "product")

You need to either put the fields you want users to search by default into a fieldset called "default":

fieldset default { # in schema, outside the document block
    fields: wpsolr_title, my_other_field, ...
}

or specify the default field or fieldset to be used for the user query:

select * from wpsolr1 where {defaultIndex:"wpsolr_title"}userInput(@userQuery)

Tip: You can always see the query that is produced by passing tracelevel=1 as a HTTP parameter.

Jon
  • 2,043
  • 11
  • 9
  • 1
    As stated, a fieldset is indeed mandatory in my use case. I failed to mention that my document type was inherited from a parent document type. In the parent schema file, I defined a fieldset, mistakenly thinking that field sets are also inherited. – WPSOLR Apr 02 '23 at 10:34