MarkLogic get data from collection - java

Is it possible to get data from MarkLogic xml database, but using MarkLogic API for java?
I have read documentation, but it only shows how to add a xml to collection or to delete it, doesn't show how to get all xml documents from one selected collection?

This looks like it will do the job
https://docs.marklogic.com/javadoc/client/index.html?com/marklogic/client/query/StructuredQueryBuilder.html
StructuredQueryBuilder.CollectionConstraintQuery collectionConstraint(String constraintName, String... uris)
Matches documents belonging to at least one of the criteria collections with the specified constraint.

Related

Most Recent Document from each CollectionGroup

How do I query the MOST RECENT DOCUMENT from each CollectionGroup in Cloud Firestore?
Just one document from each Collection in the Group, the most RECENT!
Just one document from each Collection in the Group, the most RECENT!
You cannot. When you are using a CollectionGroup query, you are retrieving all documents that exist in all collections that have a specific name. If two of the most recent documents exist within the same collection/subcollection, both will be retrieved. You cannot tell Firestore to get a single document from within each collection, unless you create a separate query for each one of them and use a limit(1) call.

How to index a XML file with Lucene [duplicate]

I am new in lucene I want to indexing with lucene of large xml files(15GB) that contain plain text as well as attribute and so many xml tags. how to parse and indexing this xml file using lucene with any sample and if we use lucene we need any database
How to parse and index huge xml file using lucene ? Any sample or links would be helpful to me to understand the process. Another one, if I use lucene, will I need any database, as I have seen and done indexing with Databases..
Your indexing would be build as you would have done using a database, just iterate through all data you want to index and write it to the index. Just go with the XmlReader class to parse your xml in a forward-only fashion. You will, just as with a database, need to index some kind of primary-key so you know what the search result represents.
A database helps when it comes to looking up the indexed data from the primary-key. It will be messy to read the data for a primary-key if you need to iterate a 15 GiB xml file at every request.
A database is not required, but it helps a lot. I would build this as an import tool that reads your xml, dumps it into your database, and then use your "normal" database indexing code you've built before.
You might like to look at Michael Sokolov's Lux product, which combines Lucene and Saxon:
http://www.mail-archive.com/solr-user#lucene.apache.org/msg84102.html
I haven't used it myself and can't claim to fully understand its capabilities.

How to Use SELECT Query on Xml using java

I am having an xml file which contains data from different tables.
These tables are linked to each other.
I want to access Records from the xml.
Can i write SQL select query on Xml file.
No, you cannot use SQL for XML files. Either move the data to a relational store or use a hierarchical query language.
All you can expect after such a vague question is a bunch of random keywords (like XQuery, eXist, XPath, Oracle XML Db, MarkLogic, Jaxen). Probably none of them is relevant to whatever problem you might have at hand.

How to get all documents from couchdb using lightcouch api in java

Is there any way to get all documents from a db rather than specifying an id and retrieving a single document using lightcouch api in Java.Presently i am using the method
JsonObject json = dbClient.find(JsonObject.class, "some-id")
to retrieve a single document.
Thanks in advance.
How about the _all_docs view? That will return a list of all the docs in the database. Or if you include include_docs=true to the request, you will also get the contents of the documents.
Try this... use a view that emits documents, but don't send any key values. There is a chance you will get all the documents of the type you specified. Also, a warning... if you use a LightCouch view, you might need to retrieve the id's of your documents, then get your actual data by "finding" it using those id's.

Data Retrieving from XML file with some limitation in Java

I am using XML in my project for data to be Insert/Update/Delete.
Currently i am using XPath for doing the above operations from my Java application.
I am facing a problem while retrieving the data from XML. If there are 1000 records in the XML file i want to get the data from XML file with some limit (same as limit in a MySQL select query) in the rows, for implementing the pagination in the view page. I want to display 100 records at a time, so that end-user can click on next button to see all the 1000 records.
Can anyone tell me the best way to full-fill this requirement?
Ya, we can do it with "position()" function but the problem is i want to get the data in an sorted order. position() will return the data from the XML file respective to the given number(in XML file the data may not be in an order). So i want to read the data along with order. I am not able to find the XML query for Sorting and Paginated data in XPath.
You can consider using JAXB instead of direct XML manipulation.
As you are using XPath to access your XML data, one possibility could be the position() function to get "paginated" data from the XML. Like:
/path/to/some/element[position() >= 100 and position() <= 200]
Of course you have to store the boundaries (e.g. 100 - 200 as an example) then between user requests.
Ok, if you need sorted output aswell... as far as I know there is no sort function in pure xpath (1.0/2.0). Maybe you are using a library that offers this as an extension. Or you maybe have the possibility to use an XSLT and xsl:sort. Or you use XML binding as written in the other answer.

Categories