How to query elasticsearch without specifying which property to match - elasticsearch

I have an elasticsearch document with multiple properties, like title, body, author.
I'd like to get results from a query that matches ANY of the fields.
Usually, I'll query by specifying a property to match. I'd rather write a more flexible query that will return the whole document if any of the properties are matched.

Related

How to search result set from a result set in elasticsearch

Im tring to understand the DSL query i needed if i want to make a search from a result set i got. means i have an initial term search, then i want make another query upon the previous result.
lets say i a have 10 documents with a sharing identifier between them, each document has a description field. i want to search first all the documents containing the value 'Hello' in the description and then take their id's, and search the document containing the value 'good by'.
thanks.
No need to execute two queries, you can use filter context that will filter out the results.filter parameter will filter out documents that do not match, and will also not affect the score for matching documents.
Filter context is in effect whenever a query clause is passed to a
filter parameter, such as the filter or must_not parameters in the
bool query, the filter parameter in the constant_score query, or the
filter aggregation.
Refer this to know more about Query and Filter contexts

Is it possible to search a keyword in CTS Job fields and custom attribute both

We are implementing CTS job search. We are looking for an implementation where if user searches for a keyword, let's say "Sales", that would then show all matching results that keyword matched in CTS providing fields like: Title, Description, Category, Location, etc OR all matching results that keyword matched any Custom Attribute attached to the job.
Is it possible in Google CTS job search?
When we have passing keyword "Sales", it's only returning results that are matching to CTS core fields like title, description and so on.
After some digging on CTS documentation i found answer for my question.
There is an attribute we have to set in created Company named as "keywordSearchableJobCustomAttributes" that accepts string as field names.
A list of keys of filterable Job.custom_attributes, whose
corresponding stringValues are used in keyword searches. Jobs with
stringValues under these specified field keys are returned if any of
the values match the search keyword. Custom field values with
parenthesis, brackets and special symbols are not searchable as-is,
and those keyword queries must be surrounded by quotes.
Below are references.
https://cloud.google.com/talent-solution/job-search/docs/companies
https://cloud.google.com/talent-solution/job-search/docs/reference/rest/v4beta1/projects.companies#Company.FIELDS.keyword_searchable_job_custom_attributes

Solr returns empty result when one of fq(filter queries) consists from stopword

1.Having the next list of filter queries I would like to get some result documents basing on them
filter queries
fq=(name_text_en_us:"microwave") & fq=(name_text_en_us:"with") & fq=(name_text_en_us:"sensor")
Full url:
http://localhost:8983/solr/master/select?_=15231231220790&fq=name_text_en_us:"microwave"&fq=name_text_en_us:"with"&fq=name_text_en_us:"sensor"&indent=on&q=*:*&wt=json
I'm getting empty result.
Unfortunately I can't merge all queries in one and have to use them in a separate way.
2. I understand that since one of the filter queries consists only from a stopword - i.e. word "with" it will be parsed by SOLR as an empty string and basing on that SOLR will filter out all documents and result will be empty.
If I remove such query and leave other - SOLR returns several documents.
If there any way how I can configure SOLR to not take into account filter queries with stopwords and as a result after those get parsed and become an empty string.
In other words I would like SOLR to skip filter queries with empty string and return result basing on other from the list

Excluding specific fields from consideration in a multi_match query

We use the fields property of a multi_match query to include certain fields by wildcard. For example, we often want to construct a query that searches only the content (as opposed to title and other fields) across the various types in our system. So we include '*.content' in the fields property of our query. However, there are some cases where we might want to exclude one or more types from the search. So I'm looking for something like an exclude_fields property that would exclude those specific fields from consideration.
I realize that one way to achieve this would be to not use the wildcard and explicitly add 'Foo.content, Bar.content, ...' to the fields property, but this would be very cumbersome in our system.

Conditionally retrieve fields from elasticsearch _source based on value of another field

I have a type with a field indicating if to reveal another field. For example, for a document, if ifRevealAge is true, value of the age field should be retrieved from _source and included in query result for the document. If ifRevealAge is false, then age field should not be included in the query result for the document. Is it possible by query API?
If it is not, how to do it through java API? I think the method toXContent(XContentBuilder builder, ToXContent.Params params) of GetResponse is supposed to do so but I can't find any documentation or references for how to use the method for filtering / modifying response result conditionally. The api documentation is just too concise.
Many thanks

Resources