I know that we can query a View with multiple keys and complex keys. But the search keys by default execute on a AND condition. Is it possible to query a view with multiple search strings using an OR condition?
It is not possible to query MapReduce views with an "or" condition. There are two possible solutions:
execute two separate MapReduce queries (in series or parallel) and aggregate the results
depending on your use-case, consider Cloudant Search or Cloudant Query, both of which allow two search clauses to be OR'd together
Related
In our search application, I want to allow users to combine their previous search results using AND/OR. Basically combine the results of previously executed queries. How can I achieve this in SOLR?
If those previous queries affect ranking. If they do affect ranking (can be partial match), you need to combine them together in a main query. There can be only one main query, though it can have subqueries in other variables passed through local parameters.
However, if they are binary (match/not match) queries, such as for categories/filters/facets, then you can use Filter Queries (fq) instead. Those you can have several and each one basically reduces matches without affecting ranking.
I have multiple collections with schemas almost same. I'd like to apply certain conditions specific to each collection while other conditions are same across all collections and return a combined result set. Is this possible in Solr? Appreciate if you can share a sample query. I'm using Solr 5.3.0.
You're going to have issues with the "certain conditions specific to each collection", as there is no query support for anything like that. You're probably going to have do to the querying and merging yourself.
Otherwise as possible solution would be the "shard unification" strategy as mentioned in Query multiple collections with different fields in solr, but scoring between documents would be local to each shard.
I am using MS-SQL Server 2008, where I have created two different custom stop-list for my database. Now both the stop-list contains different stop-words. My aim is to use each of the stop-list for a specific fulltext query search result.
For example: There is a Job portal where Candidates are searching for the Jobs with some keywords, whereas Employers are searching for the right Candidates with some keywords. Now consider that there are two different stop-list that I would like to manage, one Stop-List for Job Search specific and another stop-list is for Candidate Search specific.
How can I achieve this in my SQL Query or Stored Procedure?
I don't have much FTS experience but the documentation states that stop lists are applied via full-text indexes, and only one full-text index per table or view is allowed. So applying stop lists dynamically in queries is obviously not possible.
What would be possible on the other hand is to create an indexed view on your table. Then you could put one full-text index on the table and a second one on the view, each with a different stop list. You would have to modify the queries too, of course, so that job searches use the table and candidate searches use the view (or vice versa).
If that approach doesn't work for you, then you would have to look into alternatives that have the functionality you need.
I just started exploring SolrNet. Previously I have been using MSSQL FULL TEXT.
In sql server, my query make full text searches and also have multiple joins and Where clauses. I am also using custom paging to return only the 10 rows out of millions.
I have read few solrNet docs and run sample apps provided on the blogs. All worked well so far. Just need to get an idea, What do I do with JOINS and WHERE clauses??
e.g. If user searches for Samsung, db would return 100k records, but if users searches for Samsung && City='New york' && Price >'500' then he would only get couple of thousands records.
Do I add all columns in Solr and write WHERE clauses in Solr?
What do I do about SQL JOINS?
Thanks in Advance!
There are no joins in Solr. From the Solr wiki:
Solr provides one table. Storing a set
database tables in an index generally
requires denormalizing some of the
tables. Attempts to avoid
denormalizing usually fail.
About WHERE clauses (i.e. filtering), see Querying in SolrNet, Solr query syntax, and Common Solr query parameters.
The Solr equivalent of your where clauses is to map your columns to fields and run queries based on the query syntax. A query like your example:
Samsung && City='New york' && Price >'500'
could be translated to something like this in Solr:
q=Samsung AND city:"new york" AND price:[500 TO *]
You need to take some care when you map your database to a Solr schema, specifically you will probably have to denormalize your data. See this page on the Solr wiki for more information. Basically, you can't really do complex JOINs in Solr. It's a "flat" index.
It seems there is no way to construct query with OR condition. Has anyone hit this issue or know when this will be done or any workaround.
What I want to achive something like this with OR:
query = datastore.query(kind='Article',
filters=[('url', '=', 'url1'),
('url', '=', 'url2')]
)
But this filter works as AND not OR.
OR is not a supported query construct in Google Cloud Datastore.
The current way to achieve this is to construct multiple queries client-side and combine the result sets.
For reference, you should read through the Datastore Queries documentation:
The Datastore currently only supports combining filters with the AND operator. However it's relatively straightforward to create your own OR query by issuing multiple queries and combining the results:
Python runtime supports "IN" query filter.
Note, however, that this is just a convenience: under the hood, "IN" query is translated into a series of independent queries each looking for one value on the list.