Cloudant Search feature in CouchDB Local server - lucene

I have a search index like so in Cloudant:
"indexes": {
"search-cloud": {
"analyzer": "standard",
"index": "function(doc) { index(\"keyword\", doc.name); }"
}
}
The function is a bit more intense but that is the set up.
It appears its using this? org.apache.lucene.queryparser.classic
Right now I have a local Fauxton CouchDB 1.6.1 database that I'm staging the data on but it appears that the search isn't implemented on it.
Is there a way to install this so I can make the following call to the database and get info back?
http://localhost/{DB}/_design/filters/_search/search-cloud?q={SEARCH_QUERY}

The search stack behind IBM Cloudant is powered by Apache Lucene and was open sourced awhile back. I think this article on enabling full text search in Apache CouchDB is what you're looking for.

Related

Can't Connect to Notion API

I'm Uğur,
https://developers.notion.com/reference/retrieve-a-database
https://api.notion.com/v1/databases/database_id
I used "https://www.notion.so/111111111111111111?v=222222222222222" as a database ID. (http://prntscr.com/22cn4dp)
I used "Authorization: Bearer $NOTION_API_KEY and Notion-Version: 2021-08-16" as a cURL.
I used it with Postman but I got an error.
Error Code:
{
"object": "error",
"status": 404,
"code": "object_not_found",
"message": "Could not find database with ID: 1111111111111111."
}
How do I solve it?
Notion's update has changed the location for Integration. Now you'll find it here:
Go to the database page in your workspace.
Click the ••• on the top right corner of the page.
At the bottom of the pop-up, click Add connections.
Search for and select your integration in the Search for connections... menu.
Your integration now has permission to edit the database.
I had the same issue for a few days now. The problem I had was quite simple and turns out that I just never had the workspace shared with my integration.I [checked this video][1] at around 3 mins and only then realised that you need to share your pages and databases with the integration
Your Notion-Version looks correct but your database id should be the content after your Notion page url i.e. https://www.notion.so/DatabaseiD. Also if you're using Postman your Authorization should be set to type 'Bearer Token' with the Notion API Key that you obtained from your integration found here.
I had some trouble getting notion to work with Zotero using the Notero plugin. I created the integration and created the database but I did not explicitly share the database with the integration. After sharing the database with the integration, Notero works perfectly.
To share the database with the integration after creating the database and integration
Go to the Notion page containing the database
Click the share button in the upper right corner of the Notion window
In the text box type in the name of your integration (In the picture below my integration was called "papers")
Select your Integration (the window should now resemble the picture below)
Alter a citation in Zotero to confirm that your integration works.
Did Notion redesign/update that Share popup shown in the screenshot by alluppercase? I created an internal integration, but I am only seeing "add emails or people". (And when I try to connect in my react app - I get the error - APIResponseError: Could not find database with ID)

Is it possible to get raw data from a Metabase MBQL / SQL query via the REST API?

Is there a Metabase REST API that takes a MBQL/SQL query and returns the raw data?
I can perform a MBQL query via the API in a 2-step process by doing the intermediate step of creating a Question via the Metabase web app UI and then querying the Question, but I haven't figured how how to combine MBQL with the REST API in a single step.
Some items I'd like to accomplish by having the MBQL in the API request instead of a UI-generated Question:
better version management as the MBQL query can be checked into source control with the code
better isolation as the API call won't be dependent on the question which can change
Here's some info on how to perform the 2-step process.
2-Step Process
The two step process is:
Use web app to create a MBQL/SQL Metabase Question
Use REST API to query existing Question created in web app using the Card API
Step 1) Creating Question via Web UI
Log into the web app and click the "New Question" button in the top menu.
Once your question has been created you will be directed to a URL like the following where :question-id is an integer.
Web UI endpoint: GET /question/:question-id
Note this value and use it in the API in the next step.
Note: an alternative for creating the card is to use the POST /api/card API endpoint per YakovL. This can be useful in some scenarios were UI questions/cards are desirable, but I'm also trying to avoid creating creating cards / questions in the first place, since I'm not planning on using the Metabase UI to consume them. Reasons to avoid cards for me include needing to perform extra work to verify the card query definitions haven't changed but still having the SQL in the code to create the cards, and generate a lot of unneeded question cards in the UI.
Step 2) REST API for Question Data
The API uses the term "card" for the Web UI "question" object, so make an API call to the following Card API:
API endpoint: POST /api/card/:card-id/query/:export-format
In this URL:
:card-id is the :question-id from the Web UI URL
:export-format can be json or another format
More information on the API is available in the API Documentation:
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md
Question
Is there a way to do this directly by sending the MBQL/SQL query in the API request in a single step without a pre-existing Question/Card?
Querying via raw SQL and MBQL are both available via the POST /api/dataset/ API. The documentation for the endpoint mentions the query request definition but does not define it.
I ended up doing some more research and asking on the Metabase Discourse forum. The following examples were posted by sbelak.
Raw SQL Query
I was able to successfully make a native SQL query using the go-metabase SDK to make the following request:
POST /api/dataset
Content-Type: application/json
X-Metabase-Session: <sessionId>
{
"database": 1,
"native": {
"query": "SELECT COUNT(*) FROM orders"
},
type: "native"
}
Notes:
The POST /api/dataset does not set the response Content-Type header.
There is a POST /api/dataset/json endpoint, but that does not seem to accept the native property.
To set X-Metabase-Session see github.com/goauth/metabase.
MBQL
POST /api/dataset
Content-Type: application/json
X-Metabase-Session: <sessionId>
{
"database": 1,
"type": "query",
"query": {
"source-table": 2,
"breakout": [
[
"binning-strategy", ["field-id", 14], "default"
]
],
"aggregation": [["avg", ["field-id", 17]]]
}
}
Notes:
To set X-Metabase-Session see github.com/goauth/metabase.

Microsoft Graph: Uploading files to shared library instead of user's library?

In the documentation about Upload, these request options are listed:
PUT /me/drive/items/{parent-id}:/{filename}:/content
PUT /me/drive/root:/{parent-path}/{filename}:/content
PUT /me/drive/items/{parent-id}/children/{filename}/content
PUT /groups/<id>/drive/items/<parent-id>/children/<filename>/content
In the documentation about Resumable Uploads, Create an upload session show these options:
POST /me/drive/root:/{path-to-item}:/createUploadSession
POST /me/drive/items/{parent-item-id}:/{filename}:/createUploadSession
What if I have to upload to other (not 'me') drive? For example, the default shared library (https://mycompany.sharepoint.com/Shared%20Documents), which for any other porpoise besides uploading, the documentation says can be accessed like this:
/drives/{drive-id}/items/{item-id}
So, my question is: Is it possible to upload to "/Shared Documents"? If so, which is the right syntax for the PUT (small file) or POST (upload session)?
Perhaps something similar to this? (I just made this up, and it doesn't work)
PUT /drives/{drive-id}/items/{parent-id}/{filename}:/content
or (in case of an upload session):
POST /drives/{drive-id}/items/{parent-item-id}:/{filename}:/createUploadSession
For example, in the Graph Explorer, the response for something like this:
/v1.0/drives/THEDRIVEID/items/THEFOLDERID:/whatever.jpg:/createUploadSession
was:
{
"error": {
"code": "invalidRequest",
"message": "A valid path must be provided.",
"innerError": {
"request-id": "THERETURNEDID",
"date": "THERETURNEDDATE"
}
}
}
EDIT: Because the company's root can also be accessed as /drive/root/, I also tried (with no luck, in both 1.0 and beta):
/drive/root:/whatever.jpg:/createUploadSession
/drive/root/whatever.jpg:/createUploadSession
This is possible, but you need the right app permissions to be able to read/create files outside of the user's OneDrive. Instead of requesting Files.ReadWrite, you would need to request Sites.ReadWrite.All and then use /v1.0/drive/root:/file.bin:/createUploadSession.
You can also use the SharePoint Sites API in Microsoft Graph to access team site document libraries (other than the root site). However, this API is still in the beta version and should not be used in production apps.

Enabling Google Sitelinks Search Box?

I'm trying to enable Google Sitelinks Search Box.
It's something which allows you to display directly a "search textbox" in Google : https://developers.google.com/structured-data/slsb-overview
I've added it to the website the 27 July, using the JSON-LD syntax. According to Google, the currently cached version of website is the one of the 6 August (so a long time after deployment), but the search textbox has never appeared in Google.
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "WebSite",
"url": "https://fr.blabla.com/",
"potentialAction":
{
"#type": "SearchAction",
"target": "https://fr.blabla.com/acheter/{search_term_string}?page=1",
"query-input": "required name=search_term_string"
}
}
</script>
Sorry, I can't disclose the real URL. On the screenshot, the subdomain and the end of the URL are the real ones, the website is in HTTPS.
The "search engine" URL works fine if I call it directly.
The code is located in the head HTML segment of my page (it's not easy to test to move it, the website is a huge e-commerce platform and I can't test anything as I would).
The Google test tool (https://developers.google.com/structured-data/testing-tool/) seems to validate my code: http://i.stack.imgur.com/PyYpL.jpg
I found another website (type "cdiscount" in Google) which use it exactly like me and it looks like to work for them. The only differences I notice is they are not in HTTPS, their subdomain is www and their <script> tag is somewhere in the body.
There's two thing to consider here...
It can take Google a while to implement your code. I've seen it take a couple of months.
Adding sitelinks in the SERPs is at Google's discretion so having the code in your site is not a guarantee they will show sitelinks for the site.
So I'm afraid it's now a waiting game.
Good luck.
Actually it only takes a few days at the most after you use Fetch as Google to have the site re-crawled.
The documentation states that it is at their discretion and may depend on how busy your site is, but mine has been running under a year and isn't busy and they work. (I was surprised since I could not confirm this elsewhere).
A common mistake is not to realize how to check sitelinks, you need to search for the full website name eg blabla.com or blabla - using site:blabla.com won't show the site links.
If you want to see the Search text box as well make sure you only add the code to the home page of your site.

Connect android to database

I am doing a school project where we need to create an android application which needs to connect to a database. the application needs to gain and store information for people's profiles on the database. But unfortunatly we are a little bit stuck at this point because there are numerous ways to link the application such as http request through apache or through the SOAP/REST protocol.
But it's really hard to find good instructions or tutorials on the problem since I can't really find them. Maybe that's cause i'm probably using the wrong words on google. Unfortunately I have little relevant information. So if anyone can help me with finding relevant links to good online tutorials or howto's than those are very welcome.
I'd recommend using REST and JSON to communicate to a PHP script running on Apache. Don't worry about the database on the Android side of things, just focus on what kinds of queries you might need to make and what data you need returned. Then put together a PHP script to take those queries and generate the necessary SQL to query the database on the server. For example, You need look look up a person by name and show their address in your Android app. A REST Query is just a simple HTTP GET to request data. For example, to look up John Smith, you might request: http://www.example.org/lookup.php?name=John+Smith which will return a short JSON snippet generated by PHP:
{
name: "John Smith",
address: "1234 N Elm St.",
city: "New York",
state: "New York"
}
You can instruct PHP to use the content type text/plain by putting this at the top of your PHP script:
Then you can just navigate to the above URL in your browser and see your JSON response printed out nicely as a page. There should be a good JSON parser written in Java out there you can use with Android. Hopefully, this will get you started.
This tutorial really helped me: http://www.screaming-penguin.com/node/7742