Nextis.SmartSearch.Client

Z Podpora.nextis.cz
Přejít na: navigace, hledání

This article describes, how to implement and use Nextis.SmartSearch technology within the third party products.

Engine version 9.1.*

Prerequisites

Referenced libraries

  • Core.UI.Culture.dll (provided by Nextis)
  • Nextis.SmartSearch.Client.dll (provided by Nextis)
  • Nextis.SmartSearch.Proxy.dll (provided by Nextis)

Supporting libraries (not referenced)

  • Nextis.SmartSearch.Engine.dll (provided by Nextis)

Imports (simplified access)

  • Imports Nextis
  • Imports Nextis.SmartSearch
  • Imports Nextis.SmartSearch.Proxy

Framework

  • .NET Framework ver.: 4.6.1 and higher

Connection information

  • Authorization token (provided by Nextis)
  • Service location/address (provided by Nextis)

Implementation

Declaration of the client object

Private WithEvents Client As Nextis.SmartSearch.Client.SmartSearchClient

Initialization of the client object

Sub Initialize()
    Dim Config As New Nextis.SmartSearch.Client.SmartSearchClientConfiguration()
    With Config
        .Mode = Nextis.SmartSearch.Client.SmartSearchClient.ClientMode.RemoteWS
        .WSAddress = "smartsearch.nextis.cz:port"
        .AuthorizationToken = "token"
    End With
    Me.Client = New Nextis.SmartSearch.Client.SmartSearchClient(Config)
End Sub
Put your authorization token and address, received from Nextis, instead of the token and address, mentioned in the example.

INFO: After the initialization of client object, should be the status connected Client.Status = SmartSearchClient.ClientStatuses._initialized. If status differs from "Connected", you need to contact Nextis support to check the problem and figure it out.

Searching through the client

1.Creating the request
'Create request
Dim rq As New Nextis.SmartSearch.Proxy.SmartSearchRequest('Text to recognize', Core.UI.Culture.Languages.de)

'Enable/disable recognition options
With rq
    .AllowCar = True
    .AllowCode = True
    .AllowKBA = False 'Not implemented yet
    .AllowText = True
    .AllowVIN = True
    '.CarSpecificModelYearFrom = 1990 'Allows you to limit the vehicle specific result to vehicles, manufactured since the specified construction year
End With
Put your text to recognize into the request and choose the proper language from the enum of supported languages.
3.Sending the request
Asynchronous
Me.Client.SmartSearchAsync(rq)
  • The result is available only within the event SearchFinished
  • This method is most useful in a WinForms application
  • In case of more threads (search requests) at the same time is always returned the last one and all previous are cancelled
Synchronous
Dim rp As Nextis.SmartSearch.Proxy.SmartSearchResult = Me.Client.SmartSearch(rq)
  • The result is available within the event SearchFinished and also as a return value of the method
  • This method is most useful in a web application to manage multi-threading calls on your own
4.Getting the response
For both synchronous and asynchronous calling, you can get the result within the event Client.SearchFinished , that is also the preferred option.
Private Sub Client_SearchFinished(Data As SmartSearchResult) Handles Client.SearchFinished
    Dim Info As String = ""
    If Data.ResultState = Nextis.SmartSearch.Proxy.Definitions.ResponseStatus.Ok Then
        For Each SearchType As Nextis.SmartSearch.Proxy.Definitions.SearchTargetTypes In Data.ResultPercentage.Keys
            Info &= SearchType.ToString & ": " & Data.ResultPercentage(SearchType) & "%" & vbCrLf
        Next

        'Vehicle specific data (filed when engine decides that user is looking for specific vehicle)
        If Data.ResultPercentage(Definitions.SearchTargetTypes.Car) > 50.0 Then
            If Not Data.VehicleSpecificData Is Nothing Then
                For Each cr As SmartSearch.Proxy.VehicleSpecific.VehicleSearchResult In Data.VehicleSpecificData.Models

                    'Case when result contain only vehicle specific data (does not contain any generic articles)
                    If Data.VehicleSpecificData.Articles.Count = 0 Then
                        Dim vInfo As String = cr.ManuID & "_" & cr.ModelID & "_" & cr.EngineID & "_" & -1 & ", "
                        vInfo &= cr.ManuName + " " + cr.ModelName & ", "
                        If cr.EngineID > 0 Then
                            vInfo &= cr.EngineName & ", "
                            vInfo &= cr.EnginePowerHP & ", "
                            vInfo &= cr.EnginePowerKW & ", "
                            vInfo &= cr.EngineConstFrom & " - " & IIf(Val(cr.EngineConstTo) > 2500, " > ", cr.EngineConstTo) & ", "
                        Else
                            vInfo &= "-" & ", "
                            vInfo &= "-" & ", "
                        End If
                        vInfo &= "-"
                        vInfo &= "Ranking:" & Format(cr.RankCar * 1000, "#00000") & "_" & cr.ModelName & "_" & cr.EngineName & ", "
                        Info &= Chr(10) & vInfo
                    Else
                        'Case when result contains vehicle specific data and also generic articles
                        For Each Article As SmartSearch.Proxy.VehicleSpecific.VehicleConstructionGroup In Data.VehicleSpecificData.Articles
                            If cr.SupportedArticlesIDs.Contains(Article.ID) = True Then
                                Dim vInfo As String = cr.ManuID & "_" & cr.ModelID & "_" & cr.EngineID & "_" & Article.ID & ", "
                                vInfo &= cr.ManuName + " " + cr.ModelName & ", "
                                If cr.EngineID > 0 Then
                                    vInfo &= cr.EngineName & ", "
                                    vInfo &= cr.EnginePowerHP & ", "
                                    vInfo &= cr.EnginePowerKW & ", "
                                    vInfo &= cr.EngineConstFrom & " - " & IIf(Val(cr.EngineConstTo) > 2500, " > ", cr.EngineConstTo) & ", "
                                Else
                                    vInfo &= "-" & ", "
                                    vInfo &= "-" & ", "
                                End If
                                vInfo &= Article.Phrase & " " & " (ID " & Article.ID & ")" & ","
                                vInfo &= "Ranking:" & Format(cr.RankCar * 1000, "#00000") & "_" & cr.ModelName & "_" & cr.EngineName & "_" & Format(Article.Match, "#00000.0000")
                                Info &= Chr(10) & vInfo
                            End If
                        Next
                    End If
                Next
            End If
        End If
    Else
        Info = Data.ResultState.ToString
    End If

    Me.TextBox2.Text = Info
End Sub
The example above shows, ho to handle the result of the SmartSearch.Client. The variable Data as SmartSearchResult contains all possible information about the pattern recognition, vehicle specific data including EngineID's, GenericArticleID's if applicable and so on.
Evaluate the result

Each target type is, in the result data, represented with the percentage value of the probability, that user expects search in such a target. Percentile over 50% means high probability, percentile over 75% means almost sureness. In some moments, the percentile of some sources could reach a negative value. However, the total percentile of all targets should be always equal to 100.

Feedback from users

Methods to provide feedback, based on user choice. Implementation of this function uses machine learning to constantly improve the search and recognition results.

Work with synonyms

Currently available only for internal use and new synonyms could be imported only through the Nextis support.

Obtaining the service state

Functionality, that provides general information about the Nextis.SmartSearch service, you are connected to.
Dim ServiceInfoResponse = Me.Client.ServiceInfo
With ServiceInfoResponse
    '.ActiveLanguages (list of currently supported languages)
    '.ArticleCount (count of all available generic articles)
    '.CarModelCount (count of all available vehicle models)
    '.RelationCount (count of relations between vehicles and generic articles)
    '.ResultState (general information that request has been processed properly)
    '.Loaded (true if service is properly loaded into the memory)
End With