Assets/Watson/Scripts/Services/RetrieveAndRank/RetrieveAndRank.cs
/// <summary>
/// Adds content to a Solr index so you can search it. An example of a method that forwards to Solr. For more information about indexing, see Indexing and Basic Data Operations in the Apache Solr Reference (https://cwiki.apache.org/confluence/display/solr/Indexing+and+Basic+Data+Operations). You must commit your documents to the index to search for them. For more information about when to commit, see UpdateHandlers in SolrConfig in the Solr Reference (https://cwiki.apache.org/confluence/display/solr/UpdateHandlers+in+SolrConfig).
/// </summary>
/// <param name="callback"></param>
/// <param name="indexdataPath">Path to the file that defines the content.</param>
/// <param name="clusterID">Cluster ID.</param>
/// <param name="collectionName">Collection.</param>
/// <param name="customData"></param>
/// <returns></returns>
Adds content to a Solr index so you can search it. An example of a method that forwards to Solr. For more information about indexing, see Indexing and Basic Data Operations in the Apache Solr Reference . You must commit your documents to the index to search for them. For more information about when to commit, see UpdateHandlers in SolrConfig in the Solr Reference .
Adds content to a Solr index so you can search it . An example of a method that forwards to Solr . For more information about indexing see Indexing and Basic Data Operations in the Apache Solr Reference . You must commit your documents to the index to search for them . For more information about when to commit see UpdateHandlers in SolrConfig in the Solr Reference .
public bool IndexDocuments(OnIndexDocuments callback, string indexDataPath, string clusterID, string collectionName, string customData = default(string))
        {
            if (callback == null)
                throw new ArgumentNullException("callback");
            if (string.IsNullOrEmpty(indexDataPath))
                throw new ArgumentNullException("A index data json path is required to index documents!");
            if (string.IsNullOrEmpty(clusterID))
                throw new ArgumentNullException("A clusterID is required to index documents!");
            if (string.IsNullOrEmpty(collectionName))
                throw new ArgumentNullException("A collectionName is required to index documents!");
            IndexDocumentsRequest req = new IndexDocumentsRequest();
            req.Callback = callback;
            req.IndexDataPath = indexDataPath;
            req.ClusterID = clusterID;
            req.CollectionName = collectionName;
            req.Data = customData;
            req.Timeout = REQUEST_TIMEOUT;
            byte[] indexData;
            if (LoadFile != null)
            {
                indexData = File.ReadAllBytes(indexDataPath);
            }
            else
            {
#if !UNITY_WEBPLAYER
                indexData = File.ReadAllBytes(indexDataPath);
#endif
            }
            if (indexData == null)
                Log.Error("RetrieveAndRank", "Failed to upload {0}!", indexDataPath);
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, string.Format(SERVICE_CLUSTER_COLLECTION_UPDATE, clusterID, collectionName));
            if (connector == null)
                return false;
            req.Headers["Content-Type"] = "multipart/form-data";
            req.Forms = new Dictionary<string, RESTConnector.Form>();
            req.Forms["body"] = new RESTConnector.Form(indexData, "indexData.json", "application/json");
            req.OnResponse = OnIndexDocumentsResponse;
            return connector.Send(req);
        }
public bool IndexDocuments ( OnIndexDocuments callback , string indexDataPath , string clusterID , string collectionName , string customData = default ( string ) ) { if ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( indexDataPath ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( clusterID ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( collectionName ) ) throw new ArgumentNullException ( " " ) ; IndexDocumentsRequest req = new IndexDocumentsRequest ( ) ; req . Callback = callback ; req . IndexDataPath = indexDataPath ; req . ClusterID = clusterID ; req . CollectionName = collectionName ; req . Data = customData ; req . Timeout = REQUEST_TIMEOUT ; byte [ ] indexData ; if ( LoadFile != null ) { indexData = File . ReadAllBytes ( indexDataPath ) ; } else { if ! UNITY_WEBPLAYER indexData = File . ReadAllBytes ( indexDataPath ) ; endif } if ( indexData == null ) Log . Error ( " " , " " , indexDataPath ) ; RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , string . Format ( SERVICE_CLUSTER_COLLECTION_UPDATE , clusterID , collectionName ) ) ; if ( connector == null ) return false ; req . Headers [ " " ] = " " ; req . Forms = new Dictionary < string , RESTConnector . Form > ( ) ; req . Forms [ " " ] = new RESTConnector . Form ( indexData , " " , " " ) ; req . OnResponse = OnIndexDocumentsResponse ; return connector . Send ( req ) ; }
Adds content to a Solr index so you can search it.
Adds content to a Solr index so you can search it .
None
callback
OnIndexDocuments
None
indexDataPath
string
clusterID
string
None
collectionName
string
None
customData
string
None
indexdataPath
Path to the file that defines the content.
Path to the file that defines the content .