open search server client
TRANSCRIPT
-
8/9/2019 Open search server client
1/52
-
8/9/2019 Open search server client
2/52
o Synonyms(word and multi-terms)
o Automaticclassifications
Find out all the awesome features offered by OpenSearchServer on our
website:http://www.opensearchserver.com/
This API connector is intended to be used with PHP 5 (any version >= 5.3)
andComposer. It is based on the V2 API of OpenSearchServer.
Setup
Create a folder for your project
mkdir ossphp_sandboxcdossphp_sandbox
Create a file namedcomposer.jsonwith this content:
{ "require": { "opensearchserver/opensearchserver" : "3.0.*" }}
Run these commands to install vendors:
curl s! hps://#ecomposer.or#/insaller $php
php composer.phar insall
Create a folder where example code can be written:
mkdir %ebcd%ebecho"&'php include_once (../vendor/auoload.php()"index.php
Code can now be written in file%eb/index.php. Take examples
fromvendor/opensearchserver/opensearchserver/examples/oss_examples.php.
Quick start
A global handler must be created. It will be used to submit every request to your
OpenSearchServer instance:
+url ,(&insance -()
http://www.opensearchserver.com/http://getcomposer.org/http://www.opensearchserver.com/http://getcomposer.org/ -
8/9/2019 Open search server client
3/52
+app_ke ,(&12 ke()+lo#in ,(&lo#in()+oss_api ,ne%4pen!earch!erver56andler7arra7(url(,+url8 (ke(,+app_ke8(lo#in(,+lo#in99)
Each API request is wrapped in a particular class. Requests must be instanciated,
configured and then passed to+oss_apisubmi79that will return
an4pen!earch!erver5esponseobject.
Create an index
This code creates an index based on our "WEB_CRAWLER" template, which will
automatically create a schema allowing to easily crawl a website.
+reques ,ne%4pen!earch!erver5ndex5reae79)+requesindex7(;rs_index(9
emplae74pen!earch!erver5eques::21
-
8/9/2019 Open search server client
4/52
Index documents
While crawler is running some documents can still be manually indexed:
+documen ,ne%4pen!earch!erver5Aocumen5Aocumen 79)
+documen lan#74pen!earch!erver5eques::1BC_D9 ;eld7(ile(8(one riso(9 ;eld7(url(8 (F(9)
+documenG ,ne%4pen!earch!erver5Aocumen5Aocumen 79)+documenG lan#74pen!earch!erver5eques::1BC_D9 ;eld7(ile(8(
-
8/9/2019 Open search server client
5/52
Table of contents
How to make requests
o Create an handler
o Create a request
Create request by using an array of JSON parameters
Create request by using JSON text
o Handle response and search results
OpenSearchServer\Response\Response
OpenSearchServer\Response\ResponseIterable
OpenSearchServer\Response\SearchResult
OpenSearchServer\Response\MoreLikeThisResult
OpenSearchServer\Response\SpellCheckResult
Work with index
o Create an empty index
o Create an index with a template
o Get list of index on an instance
o Delete an indexo Check if an index exists
Instance monitoring
Configure schema
o Create a field
o Create full schema
o Get list of fields
o
Get details of a specific fieldo Delete a field
o Set default and unique field for an index
Analyzers
o Create an analyzer
https://github.com/jaeksoft/opensearchserver-php-client#how-to-make-requestshttps://github.com/jaeksoft/opensearchserver-php-client#create-an-handlerhttps://github.com/jaeksoft/opensearchserver-php-client#create-a-requesthttps://github.com/jaeksoft/opensearchserver-php-client#create-request-by-using-an-array-of-json-parametershttps://github.com/jaeksoft/opensearchserver-php-client#create-request-by-using-json-texthttps://github.com/jaeksoft/opensearchserver-php-client#handle-response-and-search-resultshttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponseresponsehttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponseresponseiterablehttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsesearchresulthttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsemorelikethisresulthttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsespellcheckresulthttps://github.com/jaeksoft/opensearchserver-php-client#work-with-indexhttps://github.com/jaeksoft/opensearchserver-php-client#create-an-empty-indexhttps://github.com/jaeksoft/opensearchserver-php-client#create-an-index-with-a-templatehttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-index-on-an-instancehttps://github.com/jaeksoft/opensearchserver-php-client#delete-an-indexhttps://github.com/jaeksoft/opensearchserver-php-client#check-if-an-index-existshttps://github.com/jaeksoft/opensearchserver-php-client#instance-monitoringhttps://github.com/jaeksoft/opensearchserver-php-client#configure-schemahttps://github.com/jaeksoft/opensearchserver-php-client#create-a-fieldhttps://github.com/jaeksoft/opensearchserver-php-client#create-full-schema-at-oncehttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-fieldshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-specific-fieldhttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-fieldhttps://github.com/jaeksoft/opensearchserver-php-client#set-default-and-unique-field-for-an-indexhttps://github.com/jaeksoft/opensearchserver-php-client#analyzershttps://github.com/jaeksoft/opensearchserver-php-client#create-an-analyzerhttps://github.com/jaeksoft/opensearchserver-php-client#how-to-make-requestshttps://github.com/jaeksoft/opensearchserver-php-client#create-an-handlerhttps://github.com/jaeksoft/opensearchserver-php-client#create-a-requesthttps://github.com/jaeksoft/opensearchserver-php-client#create-request-by-using-an-array-of-json-parametershttps://github.com/jaeksoft/opensearchserver-php-client#create-request-by-using-json-texthttps://github.com/jaeksoft/opensearchserver-php-client#handle-response-and-search-resultshttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponseresponsehttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponseresponseiterablehttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsesearchresulthttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsemorelikethisresulthttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsespellcheckresulthttps://github.com/jaeksoft/opensearchserver-php-client#work-with-indexhttps://github.com/jaeksoft/opensearchserver-php-client#create-an-empty-indexhttps://github.com/jaeksoft/opensearchserver-php-client#create-an-index-with-a-templatehttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-index-on-an-instancehttps://github.com/jaeksoft/opensearchserver-php-client#delete-an-indexhttps://github.com/jaeksoft/opensearchserver-php-client#check-if-an-index-existshttps://github.com/jaeksoft/opensearchserver-php-client#instance-monitoringhttps://github.com/jaeksoft/opensearchserver-php-client#configure-schemahttps://github.com/jaeksoft/opensearchserver-php-client#create-a-fieldhttps://github.com/jaeksoft/opensearchserver-php-client#create-full-schema-at-oncehttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-fieldshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-specific-fieldhttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-fieldhttps://github.com/jaeksoft/opensearchserver-php-client#set-default-and-unique-field-for-an-indexhttps://github.com/jaeksoft/opensearchserver-php-client#analyzershttps://github.com/jaeksoft/opensearchserver-php-client#create-an-analyzer -
8/9/2019 Open search server client
6/52
o Get list of analyzers
o Get details of a specific analyzer
Web crawler
o
Patterns Insert inclusion patterns
List inclusion patterns
Delete inclusion patterns
Insert exclusion patterns
List exclusion patterns
Delete exclusion patterns
o
Inject URL in URL databaseo Force crawling of URL
o Start web crawler
o Stop web crawler
o Get web crawler status
File crawler
o Start file crawler
o Stop file crawler
o Get file crawler status
o File repositories
Local file
FTP
SMB/CIFS
Swift
REST crawler
o List existing REST crawlers
o Execute a REST crawler
Autocompletion
o Create an autocompletion
o Build autocompletion
https://github.com/jaeksoft/opensearchserver-php-client#get-list-of-analyzershttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-specific-analyzerhttps://github.com/jaeksoft/opensearchserver-php-client#web-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#patternshttps://github.com/jaeksoft/opensearchserver-php-client#insert-inclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#list-inclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#delete-inclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#insert-exclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#list-exclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#delete-exclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#inject-url-in-url-databasehttps://github.com/jaeksoft/opensearchserver-php-client#force-crawling-of-urlhttps://github.com/jaeksoft/opensearchserver-php-client#start-web-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#stop-web-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#get-web-crawler-statushttps://github.com/jaeksoft/opensearchserver-php-client#file-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#start-file-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#stop-file-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#get-file-crawler-statushttps://github.com/jaeksoft/opensearchserver-php-client#file-repositorieshttps://github.com/jaeksoft/opensearchserver-php-client#local-filehttps://github.com/jaeksoft/opensearchserver-php-client#ftphttps://github.com/jaeksoft/opensearchserver-php-client#smbcifshttps://github.com/jaeksoft/opensearchserver-php-client#swifthttps://github.com/jaeksoft/opensearchserver-php-client#rest-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#list-existing-rest-crawlershttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-rest-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#autocompletionhttps://github.com/jaeksoft/opensearchserver-php-client#create-an-autocompletionhttps://github.com/jaeksoft/opensearchserver-php-client#build-autocompletionhttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-analyzershttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-specific-analyzerhttps://github.com/jaeksoft/opensearchserver-php-client#web-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#patternshttps://github.com/jaeksoft/opensearchserver-php-client#insert-inclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#list-inclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#delete-inclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#insert-exclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#list-exclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#delete-exclusion-patternshttps://github.com/jaeksoft/opensearchserver-php-client#inject-url-in-url-databasehttps://github.com/jaeksoft/opensearchserver-php-client#force-crawling-of-urlhttps://github.com/jaeksoft/opensearchserver-php-client#start-web-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#stop-web-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#get-web-crawler-statushttps://github.com/jaeksoft/opensearchserver-php-client#file-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#start-file-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#stop-file-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#get-file-crawler-statushttps://github.com/jaeksoft/opensearchserver-php-client#file-repositorieshttps://github.com/jaeksoft/opensearchserver-php-client#local-filehttps://github.com/jaeksoft/opensearchserver-php-client#ftphttps://github.com/jaeksoft/opensearchserver-php-client#smbcifshttps://github.com/jaeksoft/opensearchserver-php-client#swifthttps://github.com/jaeksoft/opensearchserver-php-client#rest-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#list-existing-rest-crawlershttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-rest-crawlerhttps://github.com/jaeksoft/opensearchserver-php-client#autocompletionhttps://github.com/jaeksoft/opensearchserver-php-client#create-an-autocompletionhttps://github.com/jaeksoft/opensearchserver-php-client#build-autocompletion -
8/9/2019 Open search server client
7/52
o Get list of existing autocompletion items
o Query autocompletion
o Delete an autocompletion item
Documentso Push documents
Add document with array notation
Add documents by creating
OpenSearchServer\Document\Document objects
Add documents by pushing text file
o Delete documents
o Delete documents by query
Execute search queries
o Search options
o Search(field)
Save a Search(field) query template
o Search(pattern)
Save a Search(pattern) query template
Search templates
o List search template
o Get details of a search template
o Delete a search template
Synonyms
o Create a list of synonyms
o Check if a list of synonyms exists
o Get existing lists of synonyms
o Get synonyms of a list
o Delete a list of synonyms
More like this queries
o Create a more like this query template
o Delete a more like this query template
https://github.com/jaeksoft/opensearchserver-php-client#get-list-of-existing-autocompletion-itemshttps://github.com/jaeksoft/opensearchserver-php-client#query-autocompletionhttps://github.com/jaeksoft/opensearchserver-php-client#delete-an-autocompletion-itemhttps://github.com/jaeksoft/opensearchserver-php-client#documentshttps://github.com/jaeksoft/opensearchserver-php-client#push-documentshttps://github.com/jaeksoft/opensearchserver-php-client#add-document-with-array-notationhttps://github.com/jaeksoft/opensearchserver-php-client#add-documents-by-creating-opensearchserverdocumentdocument-objectshttps://github.com/jaeksoft/opensearchserver-php-client#add-documents-by-creating-opensearchserverdocumentdocument-objectshttps://github.com/jaeksoft/opensearchserver-php-client#add-documents-by-pushing-text-filehttps://github.com/jaeksoft/opensearchserver-php-client#delete-documentshttps://github.com/jaeksoft/opensearchserver-php-client#delete-documents-using-an-existing-query-template-or-using-a-query-patternhttps://github.com/jaeksoft/opensearchserver-php-client#run-search-querieshttps://github.com/jaeksoft/opensearchserver-php-client#search-optionshttps://github.com/jaeksoft/opensearchserver-php-client#searchfieldhttps://github.com/jaeksoft/opensearchserver-php-client#save-a-searchfield-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#searchpatternhttps://github.com/jaeksoft/opensearchserver-php-client#save-a-searchpattern-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#search-templateshttps://github.com/jaeksoft/opensearchserver-php-client#list-search-templateshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-search-templatehttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-search-templatehttps://github.com/jaeksoft/opensearchserver-php-client#synonymshttps://github.com/jaeksoft/opensearchserver-php-client#create-a-list-of-synoymshttps://github.com/jaeksoft/opensearchserver-php-client#check-if-a-list-of-synonyms-existshttps://github.com/jaeksoft/opensearchserver-php-client#get-existing-lists-of-synonymshttps://github.com/jaeksoft/opensearchserver-php-client#get-synonyms-of-a-listhttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-list-of-synonymshttps://github.com/jaeksoft/opensearchserver-php-client#more-like-this-querieshttps://github.com/jaeksoft/opensearchserver-php-client#create-a-more-like-this-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-more-like-this-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-existing-autocompletion-itemshttps://github.com/jaeksoft/opensearchserver-php-client#query-autocompletionhttps://github.com/jaeksoft/opensearchserver-php-client#delete-an-autocompletion-itemhttps://github.com/jaeksoft/opensearchserver-php-client#documentshttps://github.com/jaeksoft/opensearchserver-php-client#push-documentshttps://github.com/jaeksoft/opensearchserver-php-client#add-document-with-array-notationhttps://github.com/jaeksoft/opensearchserver-php-client#add-documents-by-creating-opensearchserverdocumentdocument-objectshttps://github.com/jaeksoft/opensearchserver-php-client#add-documents-by-creating-opensearchserverdocumentdocument-objectshttps://github.com/jaeksoft/opensearchserver-php-client#add-documents-by-pushing-text-filehttps://github.com/jaeksoft/opensearchserver-php-client#delete-documentshttps://github.com/jaeksoft/opensearchserver-php-client#delete-documents-using-an-existing-query-template-or-using-a-query-patternhttps://github.com/jaeksoft/opensearchserver-php-client#run-search-querieshttps://github.com/jaeksoft/opensearchserver-php-client#search-optionshttps://github.com/jaeksoft/opensearchserver-php-client#searchfieldhttps://github.com/jaeksoft/opensearchserver-php-client#save-a-searchfield-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#searchpatternhttps://github.com/jaeksoft/opensearchserver-php-client#save-a-searchpattern-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#search-templateshttps://github.com/jaeksoft/opensearchserver-php-client#list-search-templateshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-search-templatehttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-search-templatehttps://github.com/jaeksoft/opensearchserver-php-client#synonymshttps://github.com/jaeksoft/opensearchserver-php-client#create-a-list-of-synoymshttps://github.com/jaeksoft/opensearchserver-php-client#check-if-a-list-of-synonyms-existshttps://github.com/jaeksoft/opensearchserver-php-client#get-existing-lists-of-synonymshttps://github.com/jaeksoft/opensearchserver-php-client#get-synonyms-of-a-listhttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-list-of-synonymshttps://github.com/jaeksoft/opensearchserver-php-client#more-like-this-querieshttps://github.com/jaeksoft/opensearchserver-php-client#create-a-more-like-this-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-more-like-this-query-template -
8/9/2019 Open search server client
8/52
o Get list of more like this query templates
o Get details of a more like this query template
o Execute a more like this search
Spellcheck querieso Get list of spellcheck query templates
o Delete a spellcheck query template
o Execute a spellcheck search
Scheduler
o Get status of a scheduler job
o Execute a scheduler job
Replicationo Get list of replications
o Get details about one replication
o Create or update a replication
o Start a replication
o Delete a replication
How to make requests
In this PHP client requests to OpenSearchServer's API are objects. Each request object
must be submitted to a global handler that is in charge of sending them to an
OpenSearchServer instance and returning a response.
Create an handler
+url ,(&insance -()+app_ke ,(&12 ke()
+lo#in ,(&lo#in()+oss_api ,ne%4pen!earch!erver56andler7arra7(url(,+url8 (ke(,+app_ke8(lo#in(,+lo#in99)
Create a request
https://github.com/jaeksoft/opensearchserver-php-client#get-list-of-more-like-this-query-templateshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-more-like-this-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-more-like-this-searchhttps://github.com/jaeksoft/opensearchserver-php-client#spellcheck-querieshttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-spellcheck-query-templateshttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-spellcheck-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-spellcheck-searchhttps://github.com/jaeksoft/opensearchserver-php-client#schedulerhttps://github.com/jaeksoft/opensearchserver-php-client#get-status-of-a-scheduler-jobhttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-scheduler-jobhttps://github.com/jaeksoft/opensearchserver-php-client#replicationhttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-replicationshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-about-one-replicationhttps://github.com/jaeksoft/opensearchserver-php-client#create-or-update-a-replicationhttps://github.com/jaeksoft/opensearchserver-php-client#start-a-replicationhttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-replicationhttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-more-like-this-query-templateshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-of-a-more-like-this-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-more-like-this-searchhttps://github.com/jaeksoft/opensearchserver-php-client#spellcheck-querieshttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-spellcheck-query-templateshttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-spellcheck-query-templatehttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-spellcheck-searchhttps://github.com/jaeksoft/opensearchserver-php-client#schedulerhttps://github.com/jaeksoft/opensearchserver-php-client#get-status-of-a-scheduler-jobhttps://github.com/jaeksoft/opensearchserver-php-client#execute-a-scheduler-jobhttps://github.com/jaeksoft/opensearchserver-php-client#replicationhttps://github.com/jaeksoft/opensearchserver-php-client#get-list-of-replicationshttps://github.com/jaeksoft/opensearchserver-php-client#get-details-about-one-replicationhttps://github.com/jaeksoft/opensearchserver-php-client#create-or-update-a-replicationhttps://github.com/jaeksoft/opensearchserver-php-client#start-a-replicationhttps://github.com/jaeksoft/opensearchserver-php-client#delete-a-replication -
8/9/2019 Open search server client
9/52
Several types of objects are available, each being a mapping to one API. For instance
objects of type4pen!earch!erver5ndex5reaewill be used to create index and objects
of type4pen!earch!erver5!earch5Dield5!earchwill be used to search for documents.
Each request object is a child of the abstract parent class4pen!earch!erver5eques.
For example here is the code to create a request that wil create an index when sent to
an OpenSearchServer instance:
+reques ,ne%4pen!earch!erver5ndex5reae79)
After being created each type of request must be configured in a particular way,
depending on its type, by calling some methods.
For example this code will tell OpenSearchServer to name the new index "first_index":
+requesindex7(;rs_index(9)
Important note:
methodindex79is really important and is shared by almost every type of requests.
In the case of index creation it serves to give a name to new index and in almost
every other request it will be used to configure the index on which API call must
be made.
This method will not be documented further but will be displayed in code examples
when needed.
Once configured request must be sent to an OpenSearchServer instance thanks to the
handler created before:
+response ,+oss_apisubmi7+reques9)
Create request by using an array of JSON parameters
JSON body of request can be given as an array of JSON parameters to the constructor.
If values are given this way every data set by calling specific methods on this request
will be ignored.
However some methods must still be called to set index on which work and every
parameters used directly in request's URL.
-
8/9/2019 Open search server client
10/52
Example: create a Search field template:
+json ,arra79)+jsonI(quer(J ,"es %ih values")+jsonI(searchDields(J ,arra7 arra7 ";eld","ile"8 "mode","261!="8 "boos",3 98 arra7 ";eld","conen"8 "mode","261!="8 "boos",K 99)+reques ,ne%4pen!earch!erver5!earch5Dield52u7+json9)+requesindex7(00__es_%eb(9
emplae7(es_%ih_json_values( 9)+response ,+oss_apisubmi7+reques9)
Create request by using JSON text
JSON body of request can be given as a JSON strings to the constructor. If values are
given this way every data set by calling specific methods on this request or by giving
JSON array values will be ignored.
However some methods must still be called to set index on which work and every
parameters used directly in request's URL.
Example: create a Search field template:
+json ,&&&L!4B{ "quer": "open search server"8 "sar": 08 "ro%s": F08 "lan#": "=BC!6"8 "operaor": "1BA"8
"collapsin#": { "max": G8 "mode": "4DD"8 "pe": "42M=A" }8 "reurnedDields": I "url" J8 "snippes": I
-
8/9/2019 Open search server client
11/52
{ ";eld": "ile"8 "a#": "em"8 "separaor": "..."8 "max!iNe": G008 "maxBumber": F8
"Era#mener": "B4" }8 { ";eld": "conen"8 "a#": "em"8 "separaor": "..."8 "max!iNe": G008 "maxBumber": F8 "Era#mener": "!=B
-
8/9/2019 Open search server client
12/52
Several types of responses can be returned bysubmi79. Internally this method uses a
Factory that builds a response depending on the type of Request given.
OpenSearchServer\Response\Response
Main Response class.
Methods:
o isSuccess():true if everything went well, false if there was a problem
during execution of request.
o getInfo():some requests can return some information. For examplendex
deleed: 00__es_;le.
o getRawContent():return raw JSON content of response.o getJsonValues():return an array of values built from JSON response.
Example:
+reques ,ne%4pen!earch!erver5ndex5reae79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)prin_r7+responseis!uccess799)
OpenSearchServer\Response\ResponseIterable
Extends OpenSearchServer\Response\Response. Used when response contain iterable
values. This class implements5eraorand can thus be used in a loop structure.
Example: loop through suggestions of an autocompletion query:
+reques ,ne%4pen!earch!erver51uocompleion5Quer 79)+requesindex7(00__es_;le(9 name7(auocomplee(9 quer7(coun oE(9 ro%s7F09)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Requests that use this type of response:
o OpenSearchServer\Autocompletion\Query
o OpenSearchServer\Autocompletion\GetList
-
8/9/2019 Open search server client
13/52
o OpenSearchServer\Crawler\Rest\GetList
o OpenSearchServer\Index\GetList
o OpenSearchServer\Field\GetList
o
OpenSearchServer\SearchTemplate\GetListo OpenSearchServer\MoreLikeThis\GetList
o OpenSearchServer\Analyzer\GetList
o OpenSearchServer\Synonyms\GetList
o OpenSearchServer\Crawler\Rest\GetList
o OpenSearchServer\Crawler\Web\Patterns\Exclusion\GetList
o OpenSearchServer\Crawler\Web\Patterns\Inclusion\GetList
OpenSearchServer\Response\SearchResult
Extends OpenSearchServer\Response\ResponseIterable. Used for search results.
Methods:
o getResults():return array of objects of type
OpenSearchServer\Response\Result
o getFacets():return an array of facets for this query. Each facet is an array
with key being name of field and values being array in the form&exvalue , &number oE occurrences
Example of array of facets:
1rra 7siNe,39 (hos( ,
arra 7siNe,R9 (hp://%%%.bbc.com( , in FKS (hp://%%%.Eacebook.com( , in KR (lan#( ,
arra 7siNe,G9
(en( , in K3 (es( , in FG (conen@ase
-
8/9/2019 Open search server client
14/52
getStart():return starting offset
getTotalNumberFound():return total number of results found in index for this
query
getTime():return query duration, in ms
getCollapsedDocCount():return number of total collapsed docs
getMaxScore():return max score in this results set
getNumberOfResults():return number of results in this results set
Example: this class being iterable it can also be used in a loop structure:
+reques ,ne%4pen!earch!erver5!earch5Dield5!earch79)+requesindex7(index_name(9 quer7(house(9 //usin# a precon;#ured quer emplae
emplae7(search(9)+resuls ,+oss_apisubmi7+reques9)
echo(
-
8/9/2019 Open search server client
15/52
+;eldBameis the name of the field from which the snippet has
been created.+reurnDirsTalue4nlcan be set to false to get every
snippets if several snippets where asked.
o getAvailableFields($returnAllWithoutValues = false):return all
available fields for this result.
+reurn1ll?ihouTaluescan be set to true to return fields that have
been configured asreurnedDieldsin the query even if they have no
value for this result.
o getAvailableSnippets($returnAllWithoutValues = false):return all
available snippets for this result.
+reurn1ll?ihouTaluescan be set to true to return snippets that
have been asked the query even if they have no value for thisresult.
Example:
+reques ,ne%4pen!earch!erver5!earch5Dield5!earch79)+requesindex7(index_name(9 quer7(house(9 //usin# a precon;#ured quer emplae emplae7(search(9)+resuls ,+oss_apisubmi7+reques9)
echo(
-
8/9/2019 Open search server client
16/52
Methods:
o getResults():return array of objects of type
OpenSearchServer\Response\Result
o getQuery():return query
OpenSearchServer\Response\SpellCheckResult
This response is returned by SpellCheck queries. It is used to access spell check
suggestions for each asked field.
Example:
+reques ,ne%4pen!earch!erver5!pellheck5!earch 79)
+requesindex7(index_name(9 quer7(houNe(9 emplae7(spellcheck(9)+response ,+oss_apisubmi7+reques9)var_dump7+response#e@es!pell!u##esion7(ile(99)var_dump7+response#e!pell!u##esions1rra7(ile(99)
Available methods:
getSpellSuggestionsArray(string $fieldname):return the spell suggestions for
one field as array, key is searched word and value is array of suggestions: key is
suggestion and value frequency. Array will be sorted with more frequent
suggestions at the beginning.
o Example of result
arra 7siNe,39 (houNe( ,
arra 7siNe,G9 (house( , in FG (houNN( , in P
getBestSpellSuggestion(string $fieldname):return best spell suggestion for
this field. getSpellSuggest(string $fieldname):helper method, alias
to#e@es!pell!u##esion79.
Work with index
-
8/9/2019 Open search server client
17/52
Create an empty index
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ndex5reae79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
Create an index with a template
Two pre-configured templates are offered with OpenSearchServer: WEB_CRAWLER
and FILE_CRAWLER. Each template comes with pre-configured schema, queries,
renderers.
Template?=@_1?=:+reques ,ne%4pen!earch!erver5ndex5reae79)+requesindex7(00__es_;le(9emplae74pen!earch!erver5eques::21
-
8/9/2019 Open search server client
18/52
+reques ,ne%4pen!earch!erver5ndex5Aelee 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
Check if an index exists
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ndex5=xiss 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
Instance monitoring
Several instance-wide monitoring properties can be retrieved:
+reques ,ne%4pen!earch!erver5>onior5>onior 79)+requesEull79)+response ,+oss_apisubmi7+reques9)echo(&ul()Eoreach7+response as+propBame ,+value9 { echo(&li(.+propBame.(: (.+value.(&/li()}echo(&/ul()
This would display for example:
availableProcessors: 4
freeMemory: 38656976
memoryRate: 12.958230285108
maxMemory: 1879048192
totalMemory: 298319872
indexCount: 59
freeDiskSpace: 24181137408
freeDiskRate: 23.061161199939
java.runtime.name: Java(TM) SE Runtime Environment
sun.boot.library.path: C:\Program Files\Java\jre7\bin
java.vm.version: 24.51-b03
http://www.opensearchserver.com/documentation/api_v2/index/exists.htmlhttp://www.opensearchserver.com/documentation/api_v2/index/exists.html -
8/9/2019 Open search server client
19/52
java.vm.vendor: Oracle Corporation
java.vendor.url:http://java.oracle.com/
...
...
Available methods:
full(boolean $full):if set to true return every available properties. Otherwise
return only some basic properties.
Configure schema
In OpenSearchServer each index must have a schema. A schema is a list of fields,
each with some properties.
Create a field
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5Dield5reae79)
+requesindex7(index_name(9 name7(ile!andard(9 indexed7rue9 analNer7(!andard1nalNer(9 sored7rue9 cop4E7(ile(9)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name): name of field to create.
indexed(boolean $indexed): tells whether or not this field must be indexed.
Indexed field can then used in full-text searchs.
analyzer(string $analyzerName): analyzer to use on this field. Analyzer allow to
apply several transformations on indexed or searched data.
http://java.oracle.com/http://www.opensearchserver.com/documentation/api_v2/field/create_update.htmlhttp://java.oracle.com/http://www.opensearchserver.com/documentation/api_v2/field/create_update.html -
8/9/2019 Open search server client
20/52
stored(boolean $stored): tells whether or not this field must be stored. Stored
field can return their original values in search queries, even if some Analyzers
transformed it.
copyOf(string/array $fields): field(s) from which copy value. Value is copied
before transformation by analyzers. A string or an array of string can be given to
this method.
Create full schema at once
Schema can be totally created at once using some JSON Text or JSON array of values
with object of type4pen!earch!erver5Dield5reae@ulk.+json ,&&&L!4BI
{ "name": "uniqued"8 "indexed": "U=!"8 "sored": "B4" }8 { "name": "ile"8 "indexed": "U=!"8 "sored": "U=!"8 "analNer": "
-
8/9/2019 Open search server client
21/52
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5Dield5Ceis79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Get details of a specific field
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5Dield5Ce79)+requesindex7(index_name(9
name7(ile!andard(9)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name): name of field to get information for.
Delete a field
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5Dield5Aelee79)+requesindex7(index_name(9 name7(ile!andard(9)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name): name of field to delete.
Set default and unique field for an index
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5Dield5!eAeEaul-nique79)+requesindex7(index_name(9 deEaulDield7(ile(9 //remove unique ;eld Eor his index uniqueDield79)
http://www.opensearchserver.com/documentation/api_v2/field/list.htmlhttp://www.opensearchserver.com/documentation/api_v2/field/get.htmlhttp://www.opensearchserver.com/documentation/api_v2/field/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/field/set_default_unique.htmlhttp://www.opensearchserver.com/documentation/api_v2/field/list.htmlhttp://www.opensearchserver.com/documentation/api_v2/field/get.htmlhttp://www.opensearchserver.com/documentation/api_v2/field/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/field/set_default_unique.html -
8/9/2019 Open search server client
22/52
+response ,+oss_apisubmi7+reques9)
Available methods:
defaultField(string $name): name of field that must be used as default field.
Default field is used for search queries when no particular field is configured in
the query. Empty value removes default field setting.
uniqueField(string $name): name of field that must be used as unique field.
Unique field is used as a primary key. Empty value removes unique field setting.
Analyzers
Create an analyzerGo to API documentation for this method
Analyzer can be created or updated using some JSON Text or JSON array of values
with object of type4pen!earch!erver51nalNer5reae.+json ,&&&L!4B{ "quer
-
8/9/2019 Open search server client
23/52
L!4B)+reques ,ne%4pen!earch!erver51nalNer5reae 7null8 +json9)+requesindex7(index_name(9 name7(
-
8/9/2019 Open search server client
24/52
Available methods for Insert and Delete classes:
pattern(string $pattern): URL to insert or delete
patterns(array $patterns): array of URL to insert or delete
Insert inclusion patterns
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb52aerns5nclusion5nser 79)+requesindex7(index_name(9 paern7(hp://%%%.%ebsieF.com/*(9 paerns7arra7(hp://%%%.cnn.com/spor/*(8(hp://%%%.cbc.com/ne%s/paricularpa#e.hml( 99)+response ,+oss_apisubmi7+reques9)
List inclusion patterns
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb52aerns5nclusion5Ceis 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Delete inclusion patterns
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb52aerns5nclusion5Aelee 79)+requesindex7(index_name(9 paern7(hp://%%%.%ebsieF.com/*(9)+response ,+oss_apisubmi7+reques9)
Insert exclusion patterns
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb52aerns5=xclusion5nser 79)+requesindex7(index_name(9 paern7(hp://%%%.exclude.com/*(9
http://www.opensearchserver.com/documentation/api_v2/WEB_crawler/inclusion_patterns/insert.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/inclusion_patterns/list.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/inclusion_patterns/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/exclusion_patterns/insert.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/inclusion_patterns/insert.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/inclusion_patterns/list.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/inclusion_patterns/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/exclusion_patterns/insert.html -
8/9/2019 Open search server client
25/52
paerns7arra7(hp://%%%.excludeF.com/pa#eF(8(hp://%%%.excludeG.ne/pa#eF(99)+response ,+oss_apisubmi7+reques9)
List exclusion patterns
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb52aerns5=xclusion5Ceis 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Delete exclusion patterns
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb52aerns5=xclusion5Aelee 79)+requesindex7(index_name(9 paern7(hp://%%%.excludeF.com/pa#eF(9)+response ,+oss_apisubmi7+reques9)
Inject URL in URL database
In addition to inserting pattern it is also needed to tell crawler which URL it should use tostart crawling. It will then discover automatically new URLs to crawl.
+reques ,ne%4pen!earch!erver5ra%ler5?eb5-rl5nser 79)+requesindex7(index_name(9 urls7arra7(hp://%%%.cnn.com/spor(8 (hp://%ebsieF.com(99)+response ,+oss_apisubmi7+reques9)
Force crawling of URL
Same as "Manual crawl" in OpenSearchServer's interface. Given URL must be ininclusion patterns.
+reques ,ne%4pen!earch!erver5ra%ler5?eb5ra%l 79)+requesindex7(index_name(9 url7(hp://%%%.cnn.com/spor(9)+response ,+oss_apisubmi7+reques9)
http://www.opensearchserver.com/documentation/api_v2/WEB_crawler/exclusion_patterns/list.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/exclusion_patterns/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/exclusion_patterns/list.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/exclusion_patterns/delete.html -
8/9/2019 Open search server client
26/52
Start web crawler
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb5!ar 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
Stop web crawler
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb5!op79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
Get web crawler status
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5ra%ler5?eb5Ce!aus 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
File crawler
Start file crawler
+reques ,ne%4pen!earch!erver5ra%ler5Dile5!ar79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
Available method:
run($runType):run crawleronceorEorever. Defaults toEorever.
Stop file crawler
+reques ,ne%4pen!earch!erver5ra%ler5Dile5!op79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
http://www.opensearchserver.com/documentation/api_v2/WEB_crawler/start.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/stop.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/status.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/start.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/stop.htmlhttp://www.opensearchserver.com/documentation/api_v2/WEB_crawler/status.html -
8/9/2019 Open search server client
27/52
Get file crawler status
+reques ,ne%4pen!earch!erver5ra%ler5Dile5Ce!aus 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)
var_dump7+response#enEo799)
File repositories
Every type of location share some common methods for insertion:
... pah7(/;les/invoices(9 i#nore6iddenDile7rue9 include!ubAirecor7rue9 enabled7rue9
dela7F009)...
Available methods:
path(string $path)
ignoreHiddenFile(boolean $ignoreHiddenFile)
includeSubDirectory(boolean $includeSubDirectory)
enabled(string $path):enable/disable this location
delay(int $delay):delay between each access to a file, in ms.
Local file
Insert local file location
+reques ,ne%4pen!earch!erver5ra%ler5Dile5eposior5ocalDile5nser 79)+requesindex7(index_name(9 pah7(/archives/pdE(9 i#nore6iddenDile7rue9 include!ubAirecor7rue9 enabled7rue9 dela7F009)+response ,+oss_apisubmi7+reques9)
Delete local file location
+reques ,ne%4pen!earch!erver5ra%ler5Dile5eposior5ocalDile5Aelee 79)+requesindex7(index_name(9
-
8/9/2019 Open search server client
28/52
pah7(/archives/pdE(9)+response ,+oss_apisubmi7+reques9)
One method must be called to target location to delete.
Available method:
path(string $path):path of location to delete
FTP
Insert FTP location
+reques ,ne%4pen!earch!erver5ra%ler5Dile5eposior5Dp5nser 79)+requesindex7(index_name(9 pah7(/archives/oXce_documens( 9
i#nore6iddenDile7rue9 include!ubAirecor7rue9 enabled7rue9 dela7F009 username7(user(9 pass%ord7(pKOO%0rA(9 hos7(Ep.hos.ne(9 ssl7rue9)+response ,+oss_apisubmi7+reques9)
Available methods:
username(string $username)
password(string $password)
host(string $host)
ssl(boolean $isSsl):if set to true uses FTP over SSL.
Delete FTP location
+reques ,ne%4pen!earch!erver5ra%ler5Dile5eposior5Dp5Aelee 79)+requesindex7(index_name(9
pah7(/archives/oXce_documens( 9 username7(user(9 hos7(Ep.hos.ne(9 ssl7rue9)+response ,+oss_apisubmi7+reques9)
Several methods must be called to target location to delete.
-
8/9/2019 Open search server client
29/52
Available methods:
path(string $path):path of location to delete
username(string $username)
host(string $host)
ssl(boolean $isSsl):set to true if location to delete uses FTP over SSL
SMB/CIFS
Insert SMB/CIFS location
+reques ,ne%4pen!earch!erver5ra%ler5Dile5eposior5!mb5nser 79)+requesindex7(index_name(9 pah7(/archives/pdE(9
i#nore6iddenDile7rue9 include!ubAirecor7rue9 enabled7rue9 dela7F009 username7(user(9 pass%ord7(pKOO%0rA(9 domain7(mdomain(9 hos7(mhos.ne(9)+response ,+oss_apisubmi7+reques9)
Available methods:
username(string $username)
password(string $password)
domain(string $domain)
host(string $host)
Delete SMB/CIFS location
+reques ,ne%4pen!earch!erver5ra%ler5Dile5eposior5!mb5Aelee 79)+requesindex7(index_name(9
pah7(/archives/pdE(9 username7(user(9 domain7(mdomain(9 hos7(mhos.ne(9)+response ,+oss_apisubmi7+reques9)
Several methods must be called to target location to delete.
-
8/9/2019 Open search server client
30/52
Available methods:
path(string $path):path of location to delete
username(string $username)
domain(string $domain)
host(string $host)
Swift
Insert Swift location
+reques ,ne%4pen!earch!erver5ra%ler5Dile5eposior5!%iE5nser 79)+requesindex7(index_name(9 pah7(/archives/pdE(9
i#nore6iddenDile7rue9 include!ubAirecor7rue9 enabled7rue9 dela7F009 username7(user(9 pass%ord7(pKOO%0rA(9 enan7(menan(9 conainer7(conainer_main(9 auh-rl7(hp://auh.example.com(9auh
-
8/9/2019 Open search server client
31/52
+response ,+oss_apisubmi7+reques9)
Several methods must be called to target location to delete.
Available methods:
path(string $path):path of location to delete
username(string $username)
container(string $container)
REST crawler
List existing REST crawlers
+reques ,ne%4pen!earch!erver5ra%ler5es5Ceis 79)+requesindex7(00__es_;le(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Execute a REST crawler
+reques ,ne%4pen!earch!erver5ra%ler5es5=xecue79)+requesindex7(00__es_;le(9 name7(es__cra%ler(9)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name): name of REST crawler to execute.
Autocompletion
Create an autocompletion
Go to API documentation for this method
http://www.opensearchserver.com/documentation/api_v2/auto-completion/create_update.htmlhttp://www.opensearchserver.com/documentation/api_v2/auto-completion/create_update.html -
8/9/2019 Open search server client
32/52
Autocompletion are "sub-index" for OpenSearchServer. They need to be created and
configured with fields to use for suggestions.
+reques ,ne%4pen!earch!erver51uocompleion5reae 79)+requesindex7(00__es_;le(9
name7(auocomplee(9 ;eld7(auocomplee(9)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name):name of autocompletion item to create.
field(string $name):name of field in main schema from which suggestion are
returned.
fields(array $fields):** helper method, calls;eld79
for each item in array.
Build autocompletion
Go to API documentation for this method
Autocompletion sub-index need to be re-built frequently, when content on main index
changes. This can be automatized with OpenSearchServer's Schedulers or done by
calling this API.
+reques ,ne%4pen!earch!erver51uocompleion5@uild 79)+requesindex7(index_name(9 name7(auocomplee(9)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name):name of autocompletion item to build.
Get list of existing autocompletion itemsGo to API documentation for this method
Several autocompletion items can be built, each with particular fields for some specific
purpose.
http://www.opensearchserver.com/documentation/api_v2/auto-completion/build.htmlhttp://www.opensearchserver.com/documentation/api_v2/auto-completion/list.htmlhttp://www.opensearchserver.com/documentation/api_v2/auto-completion/build.htmlhttp://www.opensearchserver.com/documentation/api_v2/auto-completion/list.html -
8/9/2019 Open search server client
33/52
+reques ,ne%4pen!earch!erver51uocompleion5Ceis 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)
}
Query autocompletion
Go to API documentation for this method
+reques ,ne%4pen!earch!erver51uocompleion5Quer 79)+requesindex7(index_name(9 name7(auocomplee(9 quer7(usk(9 ro%s7F09)
+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Available methods:
name(string $name): name of autocompletion item to query.
query(string $keywords): keywords to use for suggestions. Usually beginning of
a word. rows(int $numberOfRows): number of suggestions to return.
Delete an autocompletion item
Go to API documentation for this method
+reques ,ne%4pen!earch!erver51uocompleion5Aelee 79)+requesindex7(index_name(9 name7(auocomplee(9)
+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name): name of autocompletion item to delete.
http://www.opensearchserver.com/documentation/api_v2/auto-completion/query.htmlhttp://www.opensearchserver.com/documentation/api_v2/auto-completion/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/auto-completion/query.htmlhttp://www.opensearchserver.com/documentation/api_v2/auto-completion/delete.html -
8/9/2019 Open search server client
34/52
Documents
Push documents
Go to API documentation for this method
Add document with array notation
+reques ,ne%4pen!earch!erver5Aocumen52u79)+requesindex7(index_name(9)+requesaddAocumen7arra7 (lan#(,4pen!earch!erver5eques::1BC_D8 (;elds(,arra7 arra7
(name(,(uri(8 (value(,(F( 98 arra7 (name(,(ile(8 (value(,(oneriso8 1lexandre Aumas( 98 arra7 (name(,(ile(8 (value(,(>uliple value Eor ;eld ile( 98 arra7 (name(,(auocomplee(8 (value(,(oneriso8 1lexandre Aumas( 98 arra7 (name(,(conen(8 (value(,("Ter rue8" said >one riso) "i is unnecessar8 %e kno% eachoher so %ellY""4n he conrar8" said he coun8 "%e kno% so lile oE each oher.""ndeed'" said >one riso8 %ih he same indomiable coolness) "le us see. 1re ouno he soldier Dernand %ho desered on he eve oE he bale oE ?aerloo' 1re ou nohe ieuenan Dernand %ho served as #uide and sp o he Drench arm in !pain' 1reou no he apain Dernand %ho beraed8 sold8 and murdered his beneEacor8 1li' 1ndhave no all hese Dernands8 unied8 made ieuenanCeneral8 he oun oE >orcerE8
peer oE Drance'""4h8" cried he #eneral8 as iE branded %ih a ho iron8 "%rech8Zo reproach me %ih mshame %hen abou8 perhaps8 o kill meY Bo8 did no sa %as a sran#er o ou.(98 9 99)+response ,+oss_apisubmi7+reques9)
http://www.opensearchserver.com/documentation/api_v2/document/put_json.htmlhttp://www.opensearchserver.com/documentation/api_v2/document/put_json.html -
8/9/2019 Open search server client
35/52
Add documents by creating
OpenSearchServer\Document\Document objects
+documen ,ne%4pen!earch!erver5Aocumen5Aocumen 79)+documenlan#74pen!earch!erver5eques::1BC_D9 ;eld7(ile(8(
-
8/9/2019 Open search server client
36/52
Text files in CSV or TTL can be pushed to OpenSearchServer, with a regexp pattern to
match fields.
+daa ,&&&eun#suroire8 an older man deridesd(1ra#nan(s horse and8 Eeelin# insuled8 d(1ra#nan demands o ;#h a duel %ih him.
onsieur de uskeeers8 is solen. A(1ra#nan resolves o aven#e himselE upon he man8 %hois laer revealed o be he ome de ocheEor8 an a#en oE ardinal ichelieu8 %ho is in>eun# o pass orders Erom he ardinal o >ilad de ?iner8 anoher oE his a#ens.)enO)
-
8/9/2019 Open search server client
37/52
Delete documents
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5Aocumen5Aelee 79)+requesindex7(index_name(9 ;eld7(id(9 value7(3(9 values7arra7(K(8(O(8(P(99)+response ,+oss_apisubmi7+reques9)
Available methods:
field(string $name): name of field on which base deletion.
value(string $value): value of the field to delete.
values(array $values): helper method. Callvalue79for each item in array.
Delete documents using an existing query template or
using a query pattern
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5Aocumen5Aelee@Quer 79)+requesindex7"00__es"9
quer7(ile:I* oreore
-
8/9/2019 Open search server client
38/52
Search options
Two types of search queries exist in OpenSearchServer : Search field and Search
pattern.
They both offer lots of common options and only differ in the way of specfiying searched
fields:
+reques ,ne%...)+requesindex7(index_name(9 empeurns1ll79 quer7(house(9 //se operaor o use %hen muliple ke%ords operaor74pen!earch!erver5!earch5!earch::42=1
-
8/9/2019 Open search server client
39/52
o operator(string $operator):Set the default operator: OR or AND
o lang(string $lang):
o enableLogs(boolean value):Enale logging of this query
o
returnedFields(array $fields):An array of fieldnames to return withresults
o rows(int $rows):
o template(string $name):set name of query template to use. If set, query
will use given registered query template but will override every parameters
defined in the query object.
o snippet():
Sorting options
o sort(string $field, string $direction):add a sorting on one field. Can be
called multiple times to successively sort on different fields.
o sorts(array $sorts, string $direction):helper method. Callssor79for
each item in array.
Scoring options
o scoring(string $field, int $weight, boolean $ascending, type $type):
Facetting options
o facet(string $field, int $min = 0, boolean $multi = false, boolean
$postCollapsing = false):compute facet for one field: this will return
count of every different values for this field. Facets can be used through
#eDaces79when workingh with
an4pen!earch!erver5esponse5!earchesulobject. You can find more
details in theproper section.
Filtering options
o queryFilter(string $filter):add a filter with a pattern query. For
example :lan#:en.
o negativeFilter(string $filter):add a negative query filter.
o geoFilter(string $shape, string $unit, int $distance):add a geo filter.
o negativeGeoFilter(string $shape, string $unit, int $distance):add a
negative geo filter
https://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsesearchresulthttps://github.com/jaeksoft/opensearchserver-php-client#opensearchserverresponsesearchresult -
8/9/2019 Open search server client
40/52
o relativeDateFilter(string $field, string $fromUnit, int $fromInterval,
string $toUnit, int $toInterval, string $dateFormat, boolean
$isNegative):: add a RelativeDateFilter. This filter allows dynamic date
filtering.
This filter can be used to simplify date filtering, or when saving a
Search template. If a template is saved with a relative date filter it
will always force a date filter base on current date. For example if
set with valuesErom-ni= days,Eromnerval= 30,o-ni=
days,onerval= 0 anddaeDorma=>>ddthis search
template will always filter documents whose chosen filtered field
contains a date in last 30 days. For instance if $field is
"fileSystemDate" and if a search is run on february 1st of 2014 it will
translates to this filter:;le!semAae:IG0FK0F0F
-
8/9/2019 Open search server client
41/52
o negativeRelativeDateFilter(string $field, string $fromUnit, int
$fromInterval, string $toUnit, int $toInterval, string $dateFormat,
boolean $isNegative):: add a negative RelativeDateFilter.
o filter(string $field):helper method, alias toquerDiler79.
o filterField(string $field, string / array $filter, string $join, boolean
$addQuotes):other way to add a query filter.
Parameters:
+;eld: name of field on which apply filter.
+;ler: value(s) on which filter.
+join: if $filter is an array of values, type of join to use
between values: OR or AND.
+addQuoes: whether to add quotes around filtered values or
not.
Collapsing options
o collapsing(string $field, int $max, string $mode, string $type):
Join options
o join(string $indexName, string $queryTemplate, string $queryString,
string $localField, string $foreignField, string $type, boolean
$returnFields, boolean $returnScores, boolean $returnFacets):
Search(field)
Go to API documentation for this method
Fields that must be searched are specified precisely in this kind of query:
+reques ,ne%4pen!earch!erver5!earch5Dield5!earch79)+requesindex7(index_name(9
... //se some search ;elds searchDields7arra7(conen(8 (url(99 //se a speci;c di\eren search ;eld %ih 4A=__1BA_261!=8 O8 F09 ...+resuls ,+oss_apisubmi7+reques9)
http://www.opensearchserver.com/documentation/api_v2/searching_using_fields/search.htmlhttp://www.opensearchserver.com/documentation/api_v2/searching_using_fields/search.html -
8/9/2019 Open search server client
42/52
Available methods:
searchField(string $field, string $mode, int $boost, int $phraseBoost):
searchFields(array $fields, string $mode, int $boost, int
$phraseBoost):helper method. CallssearchDield79for each item in array.
Save a Search(field) query template
Go to API documentation for this method
Query template can be registered to be used later without having to give every
parameters. They can also be edited with the administration interface.
+reques ,ne%4pen!earch!erver5!earch5Dield52u79)
+requesindex7(index_name(9 empeurns1ll79 operaor74pen!earch!erver5!earch5!earch::42=1
-
8/9/2019 Open search server client
43/52
Query template can be registered to be used later without having to give every
parameters. They can also be edited with the administration interface.
+reques ,ne%4pen!earch!erver5!earch52aern52u79)+requesindex7(index_name(9
empeurns1ll79 operaor74pen!earch!erver5!earch5!earch::42=1
-
8/9/2019 Open search server client
44/52
name7(emplae_name(9)+response ,+oss_apisubmi7+reques9)
Synonyms
Create a list of synonyms
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5!nonms5reae79)+requesindex7(index_name(9 name7(hperonms(9 add!nonms7(couch8divan8soEa(9 add!nonms7arra7 (car8vehicle8ransporaion device(8
(keboard8elecronic device( 99)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name):name of list to create
addSynonyms(array/string $list):synonyms to add. One array entry for each
group of synonyms. The synonyms within a group are separated by commas.
Example: couch,sofa,divan
Check if a list of synonyms exists
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5!nonms5=xiss 79)+requesindex7(index_name(9 name7(___no_an_exisin#_lis___( 9)+response ,+oss_apisubmi7+reques9)var_dump7+responseis!uccess799)
Available methods:
name(string $name):name of list to check
Get existing lists of synonyms
http://www.opensearchserver.com/documentation/api_v2/synonyms/create_update.htmlhttp://www.opensearchserver.com/documentation/api_v2/synonyms/check.htmlhttp://www.opensearchserver.com/documentation/api_v2/synonyms/create_update.htmlhttp://www.opensearchserver.com/documentation/api_v2/synonyms/check.html -
8/9/2019 Open search server client
45/52
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5!nonms5Ceis 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Get synonyms of a list
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5!nonms5Ce 79)+requesindex7(index_name(9
name7(hperonms(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Available methods:
name(string $name):name of list to get
Delete a list of synonymsGo to API documentation for this method
+reques ,ne%4pen!earch!erver5!nonms5Aelee 79)+requesindex7(index_name(9 name7(hperonms(9)+response ,+oss_apisubmi7+reques9)
Available methods:
name(string $name):name of list to delete
More like this queries
Create a more like this query template
http://www.opensearchserver.com/documentation/api_v2/search_template/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/synonyms/get.htmlhttp://www.opensearchserver.com/documentation/api_v2/search_template/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/search_template/delete.htmlhttp://www.opensearchserver.com/documentation/api_v2/synonyms/get.htmlhttp://www.opensearchserver.com/documentation/api_v2/search_template/delete.html -
8/9/2019 Open search server client
46/52
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5>oreike
-
8/9/2019 Open search server client
47/52
o queryFilter(string $filter):add a filter with a pattern query. For
example :lan#:en.
o negativeFilter(string $filter):add a negative query filter.
o geoFilter(string $shape, string $unit, int $distance):add a geo filter.
o negativeGeoFilter(string $shape, string $unit, int $distance):add a
negative geo filter
o filter(string $field):helper method, alias toquerDiler79.
o filterField(string $field, string / array $filter, string $join, boolean
$addQuotes):other way to add a query filter.
Parameters:
+;eld: name of field on which apply filter.
+;ler: value(s) on which filter.
+join: if $filter is an array of values, type of join to use
between values: OR or AND.
+addQuoes: whether to add quotes around filtered values or
not.
Delete a more like this query template
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5>oreikeoreike
-
8/9/2019 Open search server client
48/52
Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)}
Get details of a more like this query templateGo to API documentation for this method
+reques ,ne%4pen!earch!erver5>oreikeoreike
-
8/9/2019 Open search server client
49/52
+reques ,ne%4pen!earch!erver5!pellheck5Ceis 79)+requesindex7(index_name(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () prin_r7+iem9)
}
Delete a spellcheck query template
+reques ,ne%4pen!earch!erver5!pellheck5Aelee 79)+requesindex7(index_name(9 emplae7(spellcheck(9)+response ,+oss_apisubmi7+reques9)
Execute a spellcheck search
+reques ,ne%4pen!earch!erver5!pellheck5!earch 79)+requesindex7(index_name(9 quer7(house(9 emplae7(spellcheck(9)+response ,+oss_apisubmi7+reques9)var_dump7+response#e@es!pell!u##esion7(ile(99)var_dump7+response#e!pell!u##esions1rra7(ile(99)
Scheduler
Get status of a scheduler job
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5!cheduler5Ce!aus 79)+requesindex7(index_name(9 name7(es job(9)+response ,+oss_apisubmi7+reques9)
Available method:
name(string $name):name of scheduler job
Execute a scheduler job
Go to API documentation for this method
http://www.opensearchserver.com/documentation/api_v2/scheduler/get_status.mdhttp://www.opensearchserver.com/documentation/api_v2/scheduler/run.mdhttp://www.opensearchserver.com/documentation/api_v2/scheduler/get_status.mdhttp://www.opensearchserver.com/documentation/api_v2/scheduler/run.md -
8/9/2019 Open search server client
50/52
+reques ,ne%4pen!earch!erver5!cheduler5un79)+requesindex7(index_name(9 name7(es job(9 variable7(url(8 (hp://%%%.opensearchserver.com(9)+response ,+oss_apisubmi7+reques9)
Available method:
name(string $name):name of scheduler job
variable(string $name, string $value):some tasks can receive variables.
variables(array $variables):helper method, callsvariable79for each item in
array.
Replication
Get list of replications
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5eplicaion5Ceis 79)+requesindex7(aricles(9)+response ,+oss_apisubmi7+reques9)Eoreach7+response as+ke ,+iem9 { echo(&br/em H(.+ke .(: () var_dump7+iem9)}
Get details about one replication
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5eplicaion5Ce79)+requesindex7(aricles(9 name7(hp://localhos:S0S0/aricles_es_repl( 9)+response ,+oss_apisubmi7+reques9)
Available method:
name(string $name):name of the replication
Create or update a replication
http://www.opensearchserver.com/documentation/api_v2/replication/list.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/get.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/list.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/get.md -
8/9/2019 Open search server client
51/52
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5eplicaion5reae79)+requesindex7(aricles(9 replicaion1B_BA=W9 remoe-rl7(hp://localhos:S0S0(9 remoendexBame7(aricles_es_repl(9)+response ,+oss_apisubmi7+reques9)
Available method:
name(string $name):name of the replication
replicationType(string $value):type of replication (use constants defined
in4pen!earch!erver5eques).
remoteUrl(string $value):URL of the target OpenSearchServer instance
remoteLogin(string $value):login for the target instance
remoteApiKey(string $value):API key
remoteIndexName(string $value):target index name
secTimeOut(string $value):timeout in secondes
Start a replication
Go to API documentation for this method
+reques ,ne%4pen!earch!erver5eplicaion5un79)+requesindex7(aricles(9 name7(hp://localhos:S0S0/aricles_es_repl( 9)+response ,+oss_apisubmi7+reques9)
Available method:
name(string $name):name of the replication
Delete a replicationGo to API documentation for this method
+reques ,ne%4pen!earch!erver5eplicaion5Aelee 79)+requesindex7(aricles(9 name7(hp://localhos:S0S0/aricles_es_repl( 9)+response ,+oss_apisubmi7+reques9)
http://www.opensearchserver.com/documentation/api_v2/replication/create_update.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/run.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/delete.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/create_update.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/run.mdhttp://www.opensearchserver.com/documentation/api_v2/replication/delete.md -
8/9/2019 Open search server client
52/52
Available method:
name(string $name):name of the replication
OpenSearchServer PHP Client Copyright 2008-2014 Emmanuel Keller /
Jaeksofthttp://www.open-search-server.com
OpenSearchServer PHP Client is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any later
version.
OpenSearchServer PHP Client is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License along with
OpenSearchServer PHP Client. If not, seehttp://www.gnu.org/licenses/.
http://www.open-search-server.com/http://www.gnu.org/licenses/http://www.open-search-server.com/http://www.gnu.org/licenses/