If i want to limit the cloudant query 'index' to certain set of documents, can i apply a selector clause at the index creation time, the same way we apply the selector clause at the time of Cloudant query.
Otherwise it ends up creating index for the specified field for the whole database.
Yes you can. However it is only for text indexes. See the documentation here.
Related
I have a SOLR DIH-conig.xml (dataimporter) with multiple queries, querying different tables (or views) in Oracle 11.
I simply want SOLR to return results from one specific query first before returning the results from the other queries.
How should I configure this in DIH-config.xml?
Thanks.
regards,
Erik
You can't configure that in data-config.xml in any way - what Solr returns is based on what's in the index. The Data Import Handler only imports data into Solr, the SQL queries aren't used for anything outside of getting data into Solr.
However you can work around this through having a special field with static values returned from each query, effectively identifying which query the document was imported from.
In your SQL query, add an aliased field name as the priority of the document:
SELECT ..., 1000 AS priority FROM ...
In the second query, do the same, but with a higher priority value:
SELECT ..., 2000 AS priority FROM ...
This require defining a long / integer field named priority first if you're not running in schemaless mode.
When querying Solr, use this value as the first sort criteria (sort=priority, score). This will give all documents from the first query first, internally sorted by score, then from the last query, also internally sorted by score.
I am trying to make a website and I'm using mongoDB to store my database. I have a question about the performance about the query findOne which I've used widely. Does this query take the whole collection from the database to the server and then perform the iteration over it or does it perform the iteration on the database and just return the document to the server? Picking up the whole collection from the server will be an issue because transferring such a huge chunk of data will take time.
Understanding how mongodb uses indexes would help you answer this question. If you pass in parameters to the findOne query, and those parameters match an index on the collection then mongodb will use the index to find your results. Without the index mongodb will need to scan the collection till it finds a match.
For example if you run a query like:
db.coll.findOne({"_id": ObjectId("5a0a0e6f29642fd7a970420c")})
then mongodb will know exactly which document you want since the _id field is unique and contains an index. If you query on another field which isn't indexed then mongodb will need to do a COLLSCAN to find the document(s) to return.
Quoting official MongoDB documentation:
findOne - Returns one document that satisfies the specified query criteria on
the collection or view. If multiple documents satisfy the query, this
method returns the first document according to the natural order which
reflects the order of documents on the disk.
Obviously implied is that the database itself will only return one collection, and in addition, you could always use postman, or console.log to check what the server returns (if you're not sure).
I want to return all the documents in a Cloudant database but only include some of the fields. I know that you can make a GET request against https://$USERNAME.cloudant.com/$DATABASE/_all_docs, but there doesn't seem to be a way to select only certain fields.
Alternatively , you can POST to /db/_find and include selector and fields in the JSON body. However, is there a universal selector, similar to SELECT * in SQL databases?
You can use {"_id":{"$gt":0}} as your selector to match all the documents, although you should note that it is not going to be performant on large data sets.
I have the schema with 10 fields. One of the fields is text(content of a file) , rest all the fields are custom metadata. Document doesn't chnages but the metadata changes frequently .
Is there any way to skip the Document(text) while re-indexing. Can I only index only custom metadata? If I skip the Document(text) in re-indexing , does it update the index file by removing the text field from the Index document?
To my knowledge there's no way to selectively update specific fields. An update operation performs a complete replace of all document data. Since Solr is open source, it's possible that you could produce your own component for this if really desired.
I have a field with indexed="no" and stored="yes" and now I need to query that field.
How can build this index after setting indexed="yes"? or I need to do a complete reindex (re-import) ?
Thanks
No, you'll need to do a complete reindex. Solr indexes a document at a time and in order to have any change done to any of its fields, the whole document will have to be reindexed.
If all your fields are stored, you might be able to write some code to have the complete reindexing done without having to fetch the data again from the data source -- you can fetch the documents from Solr and then add them back to Solr.