├── .deployment ├── functions ├── host.json ├── settings.sample.json └── pdfmetafunc │ ├── package.json │ ├── function.json │ ├── rules.json │ └── index.js ├── sample └── sample_doc.pdf ├── .gitignore ├── azuredeploy.json ├── README.md ├── search └── PDF2Search.postman_collection.json └── LICENSE /.deployment: -------------------------------------------------------------------------------- 1 | [config] 2 | project = functions 3 | -------------------------------------------------------------------------------- /functions/host.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "f148aad220b14ead9503122ca0b9b532" 3 | } -------------------------------------------------------------------------------- /sample/sample_doc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m-gagne/PDF2AzSearch/HEAD/sample/sample_doc.pdf -------------------------------------------------------------------------------- /functions/settings.sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "IsEncrypted": false, 3 | "Values": { 4 | "AzureWebJobsStorage": "", 5 | "BlobStore": "", 6 | "DocumentDBConnectionString": "Azure Document DB (SQL API) Connection String>" 7 | } 8 | } -------------------------------------------------------------------------------- /functions/pdfmetafunc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pdf2azsearch", 3 | "version": "0.0.1", 4 | "description": "Azure Function to take PDFs from Azure Storage, extract metadata (via Regular Expressions) and push to Azure Search for indexing.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"No test yet...\" && exit 1" 8 | }, 9 | "author": "Marc Gagne (https://github.com/m-gagne)", 10 | "license": "MIT", 11 | "dependencies": { 12 | "object-assign": "^4.1.1", 13 | "pdfjs-dist": "^1.8.342", 14 | "textmeta": "^0.0.1" 15 | } 16 | } -------------------------------------------------------------------------------- /functions/pdfmetafunc/function.json: -------------------------------------------------------------------------------- 1 | { 2 | "disabled": false, 3 | "bindings": [ 4 | { 5 | "name": "input", 6 | "type": "blobTrigger", 7 | "dataType": "binary", 8 | "direction": "in", 9 | "path": "inbound/{name}.pdf", 10 | "connection":"BlobStore" 11 | }, 12 | { 13 | "name": "out", 14 | "type": "documentDB", 15 | "databaseName": "documents", 16 | "collectionName": "docs", 17 | "createIfNotExists": true, 18 | "connection": "DocumentDBConnectionString", 19 | "direction": "out" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /functions/pdfmetafunc/rules.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "key": "Title", 4 | "type": "FirstSingle", 5 | "expression": "Title:\\s+([^\\n]+)", 6 | "default": "Unknown" 7 | }, 8 | { 9 | "key": "Author", 10 | "type": "FirstSingle", 11 | "expression": "Author:\\s+([^\\n]+)", 12 | "default": "Unknown" 13 | }, 14 | { 15 | "key": "Description", 16 | "type": "FirstSingle", 17 | "expression": "Description:([\\s\\S]+)Technologies used:", 18 | "default": "n/a" 19 | }, 20 | { 21 | "key": "Technologies", 22 | "type": "AllUnique", 23 | "startKeyword": "Technologies used:", 24 | "endKeyword": "Github:", 25 | "expression": "\\S\\s+([^\\n]+)", 26 | "default": "n/a", 27 | "options": { 28 | "flags": "gi" 29 | } 30 | } 31 | ] -------------------------------------------------------------------------------- /functions/pdfmetafunc/index.js: -------------------------------------------------------------------------------- 1 | const crypto = require('crypto'); 2 | const rules = require('./rules.json'); 3 | const textmeta = require('textmeta'); 4 | 5 | module.exports = function (context, document) { 6 | textmeta.extractFromPDFBuffer(document, rules).then((result) => { 7 | const uriHash = crypto.createHash('sha256') 8 | .update(context.bindingData.uri) 9 | .digest('hex'); 10 | 11 | var document = { 12 | id: uriHash, 13 | name: context.bindingData.name + ".pdf", 14 | text: result.text, 15 | last_updated: new Date(), 16 | meta: result.meta 17 | } 18 | 19 | // DEBUG LOGGING 20 | context.log("Updating document => " + document.id); 21 | context.log("Metadata found => " + JSON.stringify(document.meta, null, 4)); 22 | 23 | context.bindings.out = document; 24 | context.done(); 25 | 26 | }); 27 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Test files 2 | test.js 3 | sample_doc.docx 4 | 5 | # Exclude configuration files used by Azure CLI 6 | settings.json 7 | local.settings.json 8 | cloud.settings.json 9 | 10 | # Exclude vscode 11 | .vscode 12 | 13 | # Logs 14 | logs 15 | *.log 16 | npm-debug.log* 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (http://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules 43 | jspm_packages 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | -------------------------------------------------------------------------------- /azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "siteName": { 6 | "type": "string", 7 | "metadata": { 8 | "description": "The name of the function app that you wish to create." 9 | } 10 | }, 11 | "siteLocation": { 12 | "type": "string", 13 | "defaultValue": "West US", 14 | "metadata": { 15 | "description": "The location to use for creating the function app and hosting plan. It must be one of the Azure locations that support function apps." 16 | } 17 | } 18 | }, 19 | "variables": { 20 | "storageName": "[concat('function', uniqueString(parameters('siteName')))]", 21 | "contentShareName": "[toLower(parameters('siteName'))]", 22 | "branch": "master" 23 | }, 24 | "resources": [ 25 | { 26 | "apiVersion": "2016-03-01", 27 | "name": "[parameters('siteName')]", 28 | "type": "Microsoft.Web/sites", 29 | "properties": { 30 | "name": "[parameters('siteName')]", 31 | "siteConfig": { 32 | "appSettings": [ 33 | { 34 | "name": "AzureWebJobsDashboard", 35 | "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2015-05-01-preview').key1)]" 36 | }, 37 | { 38 | "name": "AzureWebJobsStorage", 39 | "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2015-05-01-preview').key1)]" 40 | }, 41 | { 42 | "name": "FUNCTIONS_EXTENSION_VERSION", 43 | "value": "~1" 44 | }, 45 | { 46 | "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", 47 | "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2015-05-01-preview').key1)]" 48 | }, 49 | { 50 | "name": "WEBSITE_CONTENTSHARE", 51 | "value": "[variables('contentShareName')]" 52 | }, 53 | { 54 | "name": "BlobStore", 55 | "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageName')), '2015-05-01-preview').key1)]" 56 | }, 57 | { 58 | "name": "DocumentDBConnectionString", 59 | "value": "[parameters('documentDBConnectionString')]" 60 | }, 61 | { 62 | "name": "ROUTING_EXTENSION_VERSION", 63 | "value": "~0.1" 64 | } 65 | ] 66 | }, 67 | "clientAffinityEnabled": false 68 | }, 69 | "resources": [ 70 | { 71 | "apiVersion": "2015-08-01", 72 | "name": "web", 73 | "type": "sourcecontrols", 74 | "dependsOn": [ 75 | "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]" 76 | ], 77 | "properties": { 78 | "RepoUrl": "https://github.com/m-gagne/PDF2AzSearch.git", 79 | "branch": "[variables('branch')]", 80 | "IsManualIntegration": true 81 | } 82 | } 83 | ], 84 | "dependsOn": [ 85 | "[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]" 86 | ], 87 | "location": "[parameters('siteLocation')]", 88 | "kind": "functionapp" 89 | }, 90 | { 91 | "apiVersion": "2015-05-01-preview", 92 | "type": "Microsoft.Storage/storageAccounts", 93 | "name": "[variables('storageName')]", 94 | "location": "[parameters('siteLocation')]", 95 | "properties": { 96 | "accountType": "Standard_LRS" 97 | } 98 | } 99 | ], 100 | "outputs": { 101 | "siteUri": { 102 | "type": "string", 103 | "value": "[concat('https://',reference(resourceId('Microsoft.Web/sites', parameters('siteName'))).hostNames[0])]" 104 | } 105 | } 106 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PDF to Azure Search 2 | 3 | This Azure Function binds to an [Azure Storage](https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account) Blob container and triggers when a PDF file is stored. The function extracts text from the PDF file using [pdf.js](https://github.com/mozilla/pdf.js) and using the supplies rules extracts metadata from the text & stores the result (text + metadata) in a [DocumentDB](https://azure.microsoft.com/en-us/services/cosmos-db/) collection which can then be used as a datasource for [Azure Search](https://azure.microsoft.com/en-us/services/search/). 4 | 5 | 6 | ## Prerequisites 7 | 8 | 1. You must have an active Azure Subscription, if you do not you can always start with a [free trial](https://azure.microsoft.com/en-ca/free/) 9 | 1. General understanding of 10 | * [Resource Groups](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-overview) 11 | * [Azure Storage Accounts](https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account) 12 | * [Document DB](https://docs.microsoft.com/en-us/azure/cosmos-db/introduction) 13 | * [Azure Function](https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview) 14 | * [Azure Search](https://docs.microsoft.com/en-us/azure/search/) 15 | 16 | 17 | ## Tools 18 | 19 | * The [Azure Storage Explorer](http://storageexplorer.com/) is handy for creating containers and uploading/deleting files. 20 | * [Postman](https://www.getpostman.com/) is fantastic for making REST calls and storing them for re-use. Later I will include a Postman collection for search. 21 | 22 | ## Setup 23 | 24 | ### Infrastructure 25 | 26 | 1. *Optional (but recommended)*: Create a [Resource Group](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-overview) to contain the resources you will create below. 27 | 1. Create an [Azure Storage Account](https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account) (General-Purpose or Blob, either will work) 28 | * Create a public or private (depending on your needs) blob container called `inbound` 29 | * I suggest using the [Azure Storage Explorer](http://storageexplorer.com/) tool for this. 30 | 1. Create a [Document DB (using the SQL API)](https://docs.microsoft.com/en-us/azure/cosmos-db/introduction) service, follow the steps **Create a database account** [here](https://docs.microsoft.com/en-us/azure/cosmos-db/create-documentdb-dotnet) 31 | * Be sure to create a database called `documents` and a collection called `docs` 32 | * For testing when creating your collection start with the smallest/cheapest configuration which would be 33 | * Fixed Capacity(10GB) 34 | * 400 RU's 35 | * No partition key 36 | 1. Create an [Azure Function](https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview) or use the [Azure Function Command Line](https://github.com/Azure/azure-functions-cli) utility to run this function locally 37 | * If you fork this repo you can use the [continious deployment](https://docs.microsoft.com/en-us/azure/azure-functions/functions-continuous-deployment) option. 38 | * I suggest using the `Consumption Plan` for testing and small/medium workloads. 39 | * Since you already have a storage account that you previously created, I would suggest using that instead of creating a seperate one. 40 | 1. Create an [Azure Search](https://docs.microsoft.com/en-us/azure/search/search-create-service-portal) instance 41 | * *Tip*: Use the Free pricing tier for testing! 42 | 43 | ### Configuration 44 | 45 | See [functions/settings.sample.json](functions/settings.sample.json) for all Azure Function app settings. Rename this to `local.settings.json` if running under the [Azure Function Command Line](https://github.com/Azure/azure-functions-cli) utility. 46 | 47 | 1. In you Azure Function you will need to supply a few [App Settings](https://docs.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings), specifically 48 | * `BlobStore` : The Azure Storage Account connection string which you can find in the `Access keys` blade for your Storage Account. The function will trigger whenever a .pdf file is uploaded into the `uploads` container of this storage account, again I recommend using the [Azure Storage Explorer](http://storageexplorer.com/) for this. 49 | * *Note:* `AzureWebJobsStorage` & `BlobStore` can be the same or different storage accounts depending on your needs. 50 | * `DocumentDBConnectionString` : Connection string to your Azure DocumentDB database. This can be found in the `Keys` blade of your DocumentDB under `PRIMARY CONNECTION STRING` 51 | 52 | ### Quick Test 53 | 54 | Once your funtion is running you can upload the `sample/sample_doc.pdf` into the `inbound` container, which will trigger the function. If it works you should see output in the Function logs like so: 55 | 56 | Function started (Id=28dce41e-474c-42c8-9f9b-da82072ce4fb) 57 | Updating document => dafe8948ef379e6aef78cc1b059122cebcae436d7dd878375f16094a99a9243b 58 | Metadata found => { 59 | "Title": "PDF to Text Function", 60 | "Author": "Marc Gagne", 61 | "Description": "An azure function that extracts text from PDFs, runs the regular expression captures found in rules.json \nagainst the text and stores the results in DocumentDB.", 62 | "Technologies": [ 63 | "Azure Functions", 64 | "pdf.js", 65 | "JavaScript", 66 | "Node.js" 67 | ] 68 | } 69 | Function completed (Success, Id=28dce41e-474c-42c8-9f9b-da82072ce4fb, Duration=286ms) 70 | 71 | 72 | ## Rules engine 73 | 74 | The [rules.json](functions/pdfmetafunc/rules.json) file contains the regular expressions rules that are matched against the extracted text and stored as metadata. 75 | 76 | ### rules.json basics 77 | 78 | The format for a rule is 79 | 80 | { 81 | "key": "", 82 | "type": "", 83 | "expression": "", 84 | "default": "" 85 | "startKeyword": "Optional: ", 86 | "endKeyword": "Optional: ", 87 | "options": { 88 | "flags": "" 89 | } 90 | } 91 | 92 | #### More on rules: 93 | 94 | This function uses the [TextMeta](https://github.com/m-gagne/textmeta) module which is a text extraction and rules engine. To learn more about the rules/how the text is extracted please refer to the [TextMeta GitHub repo](https://github.com/m-gagne/textmeta). 95 | 96 | ## Sample PDF 97 | 98 | The result of processing the sample file in [/sample/sample_doc.pdf](/sample/sample_doc.pdf) using the sample [rules.json](functions/pdfmetafunc/rules.json) is the following document being stored in DocumentDB: 99 | 100 | { 101 | "id": "dafe8948ef379e6aef78cc1b059122cebcae436d7dd878375f16094a99a9243b", 102 | "name": "sample_doc.pdf", 103 | "text": "Title: PDF to Text Function \nAuthor: Marc Gagne \n \nDescription: \nAn azure function that extracts text from PDFs, runs the regular expression captures found in rules.json \nagainst the text and stores the results in DocumentDB. \n \nTechnologies used: \n• Azure Functions \n• pdf.js \n• JavaScript \n• Node.js \n \nGitHub: https://github.com/m-gagne/PDF2AzSearch \n ", 104 | "last_updated": "2017-05-23T20:10:31.653Z", 105 | "meta": { 106 | "Title": "PDF to Text Function", 107 | "Author": "Marc Gagne", 108 | "Description": "An azure function that extracts text from PDFs, runs the regular expression captures found in rules.json", 109 | "Technologies": [ 110 | "Azure Functions", 111 | "pdf.js", 112 | "JavaScript", 113 | "Node.js" 114 | ] 115 | } 116 | } 117 | 118 | 119 | ## Search 120 | 121 | To configure search to index data from your Document I highly recommend getting familiar with the [Azure Search REST APIs](https://docs.microsoft.com/en-us/rest/api/searchservice/) which I find more efficient (once you learn them) than using the portal/code. 122 | 123 | The included [search/PDF2Search.postman_collection.json](search/PDF2Search.postman_collection.json) [Postman](https://www.getpostman.com/) collection contains the basics required to create the data source (DocumentDB), the index (search schema) and the indexer (reads from data source and indexes data using the configured index) as well as a very simple search query. 124 | 125 | 1. Open Postman, click `Import` and import the [search/PDF2Search.postman_collection.json](search/PDF2Search.postman_collection.json) collection. 126 | 1. Configure your [environment variables in Postman](https://www.getpostman.com/docs/environments) to include 127 | * `DocDbConnectionString` : Which is the connection string for your DocumentDB database. 128 | * Note: When setting your DocumentDB connection string as the data source, you will need to include the Database name in the string like so `AccountEndpoint=https://[your account name].documents.azure.com;AccountKey=[your account key];Database=[your database id]` 129 | * `SearchAdminKey` : Your Azure Search admin key (so you can create/delete data sources, indexes, indexers etc.) 130 | * `SearchAccountName` : The name of your Azure Search service 131 | * Note: This is just the *name* not the full *url*. 132 | 1. In the `001 - Setup` folder `Send` the `Create Data Source`, `Create Index` & `Create Indexer` requests. 133 | * You should look at the `Body` of each of these requests to better understand what they are doing 134 | 1. After a brief moment (give it a minute) you should now be able to run the `002 - Searches/Sample Query` request to search your document! -------------------------------------------------------------------------------- /search/PDF2Search.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "variables": [], 3 | "info": { 4 | "name": "PDF2Search", 5 | "_postman_id": "79a2872c-64ec-7699-6442-79074724e3cc", 6 | "description": "", 7 | "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" 8 | }, 9 | "item": [ 10 | { 11 | "name": "001 - Setup", 12 | "description": "", 13 | "item": [ 14 | { 15 | "name": "Create Data Source", 16 | "request": { 17 | "url": "https://{{SearchAccountName}}.search.windows.net/datasources?api-version=2015-02-28", 18 | "method": "POST", 19 | "header": [ 20 | { 21 | "key": "Content-Type", 22 | "value": "application/json", 23 | "description": "" 24 | }, 25 | { 26 | "key": "api-key", 27 | "value": "{{SearchAdminKey}}", 28 | "description": "" 29 | } 30 | ], 31 | "body": { 32 | "mode": "raw", 33 | "raw": "{\r\n \"name\": \"documents-source\",\r\n \"type\": \"documentdb\",\r\n \"credentials\": {\r\n \"connectionString\": \"{{DocDbConnectionString}}\"\r\n },\r\n \"container\": { \"name\": \"docs\", \"query\": \"SELECT c._ts, c.id, c.name, c.text, c.meta.Title, c.meta.Author, c.meta.Description, c.meta.Technologies FROM c WHERE c._ts >= @HighWaterMark\"},\r\n \"dataChangeDetectionPolicy\": {\r\n \"@odata.type\": \"#Microsoft.Azure.Search.HighWaterMarkChangeDetectionPolicy\",\r\n \"highWaterMarkColumnName\": \"_ts\"\r\n }\r\n}" 34 | }, 35 | "description": "" 36 | }, 37 | "response": [] 38 | }, 39 | { 40 | "name": "Delete Data Source", 41 | "request": { 42 | "url": "https://{{SearchAccountName}}.search.windows.net/datasources/documents-source?api-version=2015-02-28-Preview", 43 | "method": "DELETE", 44 | "header": [ 45 | { 46 | "key": "Content-Type", 47 | "value": "application/json", 48 | "description": "" 49 | }, 50 | { 51 | "key": "api-key", 52 | "value": "{{SearchAdminKey}}", 53 | "description": "" 54 | } 55 | ], 56 | "body": { 57 | "mode": "raw", 58 | "raw": "" 59 | }, 60 | "description": "" 61 | }, 62 | "response": [] 63 | }, 64 | { 65 | "name": "Create Index", 66 | "request": { 67 | "url": "https://{{SearchAccountName}}.search.windows.net/indexes/documents-index?api-version=2015-02-28-Preview", 68 | "method": "PUT", 69 | "header": [ 70 | { 71 | "key": "Content-Type", 72 | "value": "application/json", 73 | "description": "" 74 | }, 75 | { 76 | "key": "api-key", 77 | "value": "{{SearchAdminKey}}", 78 | "description": "" 79 | } 80 | ], 81 | "body": { 82 | "mode": "raw", 83 | "raw": "{\r\n \"@odata.context\": \"https://{{SearchAccountName}}.search.windows.net/$metadata#indexes/$entity\",\r\n \"name\": \"documents-index\",\r\n \"fields\": [\r\n {\r\n \"name\": \"id\",\r\n \"type\": \"Edm.String\",\r\n \"searchable\": false,\r\n \"filterable\": true,\r\n \"retrievable\": true,\r\n \"sortable\": false,\r\n \"facetable\": false,\r\n \"key\": true,\r\n \"indexAnalyzer\": null,\r\n \"searchAnalyzer\": null,\r\n \"analyzer\": null,\r\n \"synonymMaps\": []\r\n },\r\n {\r\n \"name\": \"name\",\r\n \"type\": \"Edm.String\",\r\n \"searchable\": true,\r\n \"filterable\": true,\r\n \"retrievable\": true,\r\n \"sortable\": true,\r\n \"facetable\": false,\r\n \"key\": false\r\n },\r\n {\r\n \"name\": \"text\",\r\n \"type\": \"Edm.String\",\r\n \"searchable\": true,\r\n \"filterable\": false,\r\n \"retrievable\": true,\r\n \"sortable\": false,\r\n \"facetable\": false,\r\n \"key\": false,\r\n \"indexAnalyzer\": null,\r\n \"searchAnalyzer\": null,\r\n \"analyzer\": \"en.microsoft\",\r\n \"synonymMaps\": []\r\n },\r\n {\r\n \"name\": \"Title\",\r\n \"type\": \"Edm.String\",\r\n \"searchable\": true,\r\n \"filterable\": true,\r\n \"retrievable\": true,\r\n \"sortable\": true,\r\n \"facetable\": false,\r\n \"key\": false,\r\n \"indexAnalyzer\": null,\r\n \"searchAnalyzer\": null,\r\n \"analyzer\": \"en.microsoft\",\r\n \"synonymMaps\": []\r\n },\r\n {\r\n \"name\": \"Author\",\r\n \"type\": \"Edm.String\",\r\n \"searchable\": true,\r\n \"filterable\": true,\r\n \"retrievable\": true,\r\n \"sortable\": true,\r\n \"facetable\": false,\r\n \"key\": false,\r\n \"indexAnalyzer\": null,\r\n \"searchAnalyzer\": null,\r\n \"analyzer\": \"en.microsoft\",\r\n \"synonymMaps\": []\r\n },\r\n {\r\n \"name\": \"Description\",\r\n \"type\": \"Edm.String\",\r\n \"searchable\": true,\r\n \"filterable\": true,\r\n \"retrievable\": true,\r\n \"sortable\": true,\r\n \"facetable\": false,\r\n \"key\": false,\r\n \"indexAnalyzer\": null,\r\n \"searchAnalyzer\": null,\r\n \"analyzer\": \"en.microsoft\",\r\n \"synonymMaps\": []\r\n }, \r\n {\r\n \"name\": \"Technologies\",\r\n \"type\": \"Collection(Edm.String)\",\r\n \"searchable\": true,\r\n \"filterable\": true,\r\n \"retrievable\": true,\r\n \"sortable\": false,\r\n \"facetable\": true,\r\n \"key\": false,\r\n \"indexAnalyzer\": null,\r\n \"searchAnalyzer\": null,\r\n \"analyzer\": \"en.microsoft\",\r\n \"synonymMaps\": []\r\n } \r\n ],\r\n \"defaultScoringProfile\": \"\",\r\n \"corsOptions\":\r\n {\r\n \"allowedOrigins\": [\"*\"]\r\n },\r\n \"suggesters\": [\r\n {\r\n \"name\": \"sg\",\r\n \"searchMode\": \"analyzingInfixMatching\",\r\n \"sourceFields\": [\"Title\", \"Technologies\"]\r\n }\r\n ],\r\n \"analyzers\": [],\r\n \"tokenizers\": [],\r\n \"tokenFilters\": [],\r\n \"charFilters\": []\r\n}" 84 | }, 85 | "description": "" 86 | }, 87 | "response": [] 88 | }, 89 | { 90 | "name": "Delete Index", 91 | "request": { 92 | "url": "https://{{SearchAccountName}}.search.windows.net/indexes/documents-index?api-version=2015-02-28-Preview", 93 | "method": "DELETE", 94 | "header": [ 95 | { 96 | "key": "Content-Type", 97 | "value": "application/json", 98 | "description": "" 99 | }, 100 | { 101 | "key": "api-key", 102 | "value": "{{SearchAdminKey}}", 103 | "description": "" 104 | } 105 | ], 106 | "body": { 107 | "mode": "raw", 108 | "raw": "" 109 | }, 110 | "description": "" 111 | }, 112 | "response": [] 113 | }, 114 | { 115 | "name": "Create Indexer", 116 | "request": { 117 | "url": "https://{{SearchAccountName}}.search.windows.net/indexers?api-version=2015-02-28-Preview", 118 | "method": "POST", 119 | "header": [ 120 | { 121 | "key": "Content-Type", 122 | "value": "application/json", 123 | "description": "" 124 | }, 125 | { 126 | "key": "api-key", 127 | "value": "{{SearchAdminKey}}", 128 | "description": "" 129 | } 130 | ], 131 | "body": { 132 | "mode": "raw", 133 | "raw": "{\r\n \"name\" : \"documents-indexer\",\r\n \"dataSourceName\" : \"documents-source\",\r\n \"targetIndexName\" : \"documents-index\",\r\n \"fieldMappings\" : []\r\n}" 134 | }, 135 | "description": "" 136 | }, 137 | "response": [] 138 | }, 139 | { 140 | "name": "Delete Indexer", 141 | "request": { 142 | "url": "https://{{SearchAccountName}}.search.windows.net/indexers/documents-indexer?api-version=2015-02-28-Preview", 143 | "method": "DELETE", 144 | "header": [ 145 | { 146 | "key": "Content-Type", 147 | "value": "application/json", 148 | "description": "" 149 | }, 150 | { 151 | "key": "api-key", 152 | "value": "{{SearchAdminKey}}", 153 | "description": "" 154 | } 155 | ], 156 | "body": { 157 | "mode": "raw", 158 | "raw": "" 159 | }, 160 | "description": "" 161 | }, 162 | "response": [] 163 | } 164 | ] 165 | }, 166 | { 167 | "name": "002 - Searches", 168 | "description": "", 169 | "item": [ 170 | { 171 | "name": "Sample Query", 172 | "request": { 173 | "url": "https://{{SearchAccountName}}.search.windows.net/indexes/documents-index/docs?api-version=2015-02-28-Preview&search=*&$count=true&$filter=Author eq 'Marc Gagne'&queryType=full", 174 | "method": "GET", 175 | "header": [ 176 | { 177 | "key": "Content-Type", 178 | "value": "application/json", 179 | "description": "" 180 | }, 181 | { 182 | "key": "api-key", 183 | "value": "{{SearchAdminKey}}", 184 | "description": "" 185 | } 186 | ], 187 | "body": {}, 188 | "description": "Compound search for tag + city using facets on provider" 189 | }, 190 | "response": [] 191 | } 192 | ] 193 | }, 194 | { 195 | "name": "003 - Management", 196 | "description": "", 197 | "item": [ 198 | { 199 | "name": "Run Indexer (Direct via Azure Search)", 200 | "request": { 201 | "url": "https://{{SearchAccountName}}.search.windows.net/indexers/documents-indexer/run?api-version=2015-02-28", 202 | "method": "POST", 203 | "header": [ 204 | { 205 | "key": "Content-Type", 206 | "value": "application/json", 207 | "description": "" 208 | }, 209 | { 210 | "key": "api-key", 211 | "value": "{{SearchAdminKey}}", 212 | "description": "" 213 | } 214 | ], 215 | "body": { 216 | "mode": "raw", 217 | "raw": "" 218 | }, 219 | "description": "" 220 | }, 221 | "response": [] 222 | } 223 | ] 224 | } 225 | ] 226 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. --------------------------------------------------------------------------------