Jump to content

Looking for advice with my Apache Solr UDF - (Moved)


ghetek
 Share

Recommended Posts

Hi everybody!

Apache Solr is an awesome search server that allows you to search through petabytes of data in milliseconds. It is used by many large organizations. It's kind of like MySQL with search in mind. 

If you would like to get started, download Apache Solr and run the example command, "bin/solr start -e techproducts"

Now the example in the UDF should work. I am looking for any advice at all before I post this into the examples area.

here is a walkthrough of what is happening in the example

Func Example()
    Local $sHost = '127.0.0.1', $sPort = 8983, $sContainer = 'techproducts', $sWow64 = ""
    If @AutoItX64 Then $sWow64 = "\Wow6432Node"
    Local $dir_autoit = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir")
    Local $st_URL = 'http://' & $sHost & ':' & $sPort & '/solr/' & $sContainer

    ;First lets see if its running, start if it is not
    If _solr_Webping($st_URL) = -1 Then _solr_cmdstart($SOLR_HOME, $sContainer)
    ;Enable stream overlay so that we can send commands via URL
    _solr_enablestreamoverlay($st_URL)
    ;delete the example data
    _solr_Webdelall($st_URL, True)
    ;Lets define some values for a document
    Local $aPairs[5][2] = [ _
            [4, Default], _
            ['literal.id', 5], _
            ['literal.value_s', 'anything'], _
            ['literal.resourcename', 'API Errors Constants'], _
            ['literal.indextime_dt',_solr_tnow()]]
    ;now package up the document with the values
    _Solr_uploadPkg($dir_autoit & '\Include\APIErrorsConstants.au3', $st_URL, $aPairs, Null, 'commit=true&overrideLiterals=true')
    ;whoops, lets make a change to a single field
    _solr_Webupdate($st_URL, '[{"id":"' & 5 & '","value_s"   : {"set":"something"}}]')
    ;and commit that change
    _solr_Webcommit($st_URL)
    ;we can also upload files from the SimplePostTool
    _solr_jarpost($SOLR_HOME & '\example\exampledocs\post.jar', $sContainer, $dir_autoit & '\Include\GuiListView.au3', 'literal.id=6&literal.cat=Help Files&commit=true')
    
    ;now we can query for something
    Local $qry_response = _solr_Webselect($st_URL, 'q=$ERROR_VOLSNAP_PREPARE_HIBERNATE')
    Local $json_response = Json_Encode($qry_response)
    json_dump($json_response)

    ConsoleWrite(json_get($qry_response, '.response.docs[0].content[0]') & @CRLF)
EndFunc   ;==>Example

 

Thank you for your time!

solr.au3 Json.au3 BinaryCall.au3

Edited by ghetek
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...