You are viewing limited content. For full access, please sign in.

Question

Question

SDk Script error - The search term you have entered is too complex to process. Please rewrite the search term and break it up into smaller search terms.

SDK
asked on May 21, 2015 Show version history

We are creating a advanced search string in sdk script, by concatenating same search for different plan values. Never had issue with it. I noticed that it works if the string repeats for up to 6 plans but after that it gives this message. Is there a limit on length of search string?

0 0

Answer

SELECTED ANSWER
replied on June 1, 2015

As a note, it is possible to do Field Value in List of Fields search: see this post.

 

P.S.: You can make code much easier to read using the "code" format:

1 0

Replies

replied on May 21, 2015

There is a lot of repetition in your searches. The folder path, account ID, effective date and account name are the same. The only thing that changes is the plan ID. It seems to be looking for a document with multiple Plan IDs (all your search terms are combined with AND ("&"), so they'll result in at most one hit). Is that what you're trying to do?

0 0
replied on May 22, 2015 Show version history

This was created few years back by another developer. I came across this issue so I looked into it. I also thought only one entry will be found but I saw multiple entries were returned having same account id etc and common plan ID.

I am not sure why he wrote it to where the same string has to repeat instead of writing like sql - 'plan ID in (list of plan IDs in metadata)'. I am not advance search expert. Do not know how to write it that way where all the plan IDs can be searched at the same time instead of using concatenation.

If you can give me example of that or suggest modification below, I will try to modify search.

 

 

 


 Dim oPlanVal as Object
            Dim mvPlanIDS() As Object = oFD.Field("Plan ID")

            If mvPlanIDS.Length = 0 Then Exit Sub

            Dim sTempl as String = oFD.Template.Name
            Dim sAcctID as String = oFD.Field("Account ID")
            Dim sAcctNm as String = oFD.Field("Account Name")
            Dim dEffDate as DateTime = oFD.Field("Effective Date")
            Dim sMarket as String = oFD.Field("Market")


            Dim oFolder as LFFolder = me.Entry.ParentFolder

            For each oPlanVal In mvPlanIDS

                If sQryStr = "" then
                    sQryStr = "{LF:LOOKIN=""" & oFolder.FullPath & """, SUBFOLDERS=0} & " & _
                        "{[" & sTempl  & "]:[Account ID]=""" & sAcctID & """, [Account Name]=""" & sAcctNm & """, [Effective Date]=""" & dEffDate.ToString("d") & """, [Plan ID]=""" & oPlanVal & """}"
                   Else
                        sQryStr = sQryStr & " & " & _
                        "{LF:LOOKIN=""" & oFolder.FullPath & """, SUBFOLDERS=0} & " & _
                        "{[" & sTempl  & "]:[Account ID]=""" & sAcctID & """, [Account Name]=""" & sAcctNm & """, [Effective Date]=""" & dEffDate.ToString("d") & """, [Plan ID]=""" & oPlanVal & """}"
                End If

            Next

            MsgBox(sQryStr)


oSearch.Command = sQryStr
            oSearch.BeginSearch(True)
            MsgBox("Search Done")

            Dim oHits As ILFCollection = oSearch.GetSearchHits
            Dim oHit as ILFSearchHit

            MsgBox("Hiit Count: " & oHits.Count)

            Dim oAcctFolder as LFFolder

            Try
                oAcctFolder = me.Database.GetEntryByPath("\" & sMarket & "\Accounts\" & sAcctNm)
            Catch ex as Exception
                oAcctFolder = me.Database.GetEntryByPath("\" & sMarket & "\Accounts")
                oAcctFolder.Create(sAcctNm, oAcctFolder, False)
                oAcctFolder = me.Database.GetEntryByPath("\" & sMarket & "\Accounts\" & sAcctNm)
            End Try

            Msgbox("Folder Made?")

            For Each oHit In oHits
                Dim oHitEntry as ILFEntry = oHit.Entry
                oHitEntry.Move(oAcctFolder, True)
            Next

 

0 0
SELECTED ANSWER
replied on June 1, 2015

As a note, it is possible to do Field Value in List of Fields search: see this post.

 

P.S.: You can make code much easier to read using the "code" format:

1 0
replied on May 28, 2015

Any idea how to change script to reduce the length?

0 0
replied on May 28, 2015

I think if you pull out the part that concatenates the path, account ID, effective date and account name out of the "For each oPlanVal In mvPlanIDS" loop and just add it on to the search string once after the loop finishes concatenating the plan IDs you'll end up with the same search but without all the repetitions.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.