Запросы Solr с ColdFusion странное поведение

Я использую ColdFusion в качестве серверного языка для своих приложений и в качестве поискового сервера я использую Solr. Разрабатывая, я врезался в стену! Синтаксис запроса url solr с фильтрацией выглядит так (без переноса строки)

http://localhost:8090/solr/areios_pagos/select?&q=*&fq=apofasi_date:(2002)&wt=json&indent=on

Эта проблема

Когда я запрашиваю solr напрямую (с определенным фильтром), я получаю успешный вывод. Запрос следующий:

http://localhost:8090/solr/areios_pagos/select?&q=*&fq=apofasi_number:(1)&wt=json&indent=on

Когда я пытаюсь построить вышеупомянутый запрос с помощью ColdFusion (см. Следующий код CFC), он завершается неудачей только с одним из фильтров (apofasi_number:()) и со звездочкой (*) со значением "q". Самое смешное, что он терпит неудачу со значением "1", а не с "66"! Я перепробовал много вещей (даже жестко закодированные аргументы). Имейте в виду, что если я запрашиваю solr напрямую, с конкретным фильтром, это работает!

<cfcomponent output="false">
<cfprocessingdirective pageencoding="utf-8">
<cfset setEncoding("URL", "utf-8")>

  <cffunction name="searchP" access="remote" returnFormat="json">         
      <cfargument name="q" type="string" default="" required="no">
      <cfargument name="fq" type="string" default="" required="no">

      <cfset theUrl = 'http://localhost/solr/areios_pagos/select/?'>

      <cfhttp method="get" url="#theUrl#" port="8090" result="rs" username="********" password="********">
        <cfhttpparam type="url" name="q" value="#q#">
        <cfhttpparam type="url" name="fq" value="#fq#">
        <cfhttpparam type="url" name="rows" value="120">
        <cfhttpparam type="url" name="wt" value="json">
        <cfhttpparam type="url" name="sort" value="score desc">
        <cfhttpparam type="url" name="hl" value="true">
        <cfhttpparam type="url" name="hl.fl" value="content,title">
        <cfhttpparam type="url" name="hl.alternateField" value="content">
        <cfhttpparam type="url" name="hl.maxAlternateFieldLength" value="850">
        <cfhttpparam type="url" name="hl.fragmenter" value="gap">
        <cfhttpparam type="url" name="hl.maxAnalyzedChars" value="-1">
        <cfhttpparam type="url" name="hl.fragsize" value="850">      
      </cfhttp>  

      <cfset theData = deserializeJson(rs.FileContent)>
      <cfset check = theData.response.numFound>

      <cfset forsolr = createObject("java", "java.util.LinkedHashMap").init() />
      <cfset forsolr['docs'] = theData.response.docs>


      <cfset docsHighlitedRaw = theData.highlighting>   

      <cfset i = 1>
      <cfset result = ArrayNew(1)>

      <cfloop collection="#docsHighlitedRaw#" item="key" >
        <cfset content = createObject("java", "java.util.LinkedHashMap").init() />
        <cfset content['solr_id'] = #key#>
        <cfset content['content'] = #docsHighlitedRaw[key].content[1]#>
        <cfset content['keywordlist'] = keyWordsExtract(#content['content']#)>
        <cfset result[i] = content>
        <cfset i = i + 1>
      </cfloop>

      <cfset forsolr1 = createObject("java", "java.util.LinkedHashMap").init() />
      <cfset forsolr1['docs'] = result> 

      <cfset result = ArrayOfStructsMerge(forsolr.docs, forsolr1.docs, "solr_id")>

      <cfif check LT 1>
            <cfset output = {"docs" = result, "success" = "false"}>
        <cfelse>
            <cfset output = {"docs" = result, "success" = "true"}>      
      </cfif>

      <cfreturn output>     

  </cffunction>



  <cffunction name="ArrayOfStructsMerge" returntype="array" access="public" output="no">
      <cfargument name="left"  type="array"  required="yes">
      <cfargument name="right" type="array"  required="yes">
      <cfargument name="id"    type="string" required="yes">

      <cfset var result = Duplicate(arguments.left)>
      <cfset var element = "">
      <cfset var key = "">
      <cfset var currentId = "">
      <cfset var lookup = StructNew()>

      <cfloop array="#result#" index="element">
        <cfif IsStruct(element) and StructKeyExists(element, arguments.id)>
          <cfset currentId = element[arguments.id]>
          <cfset lookup[currentId] = element>
        </cfif>
      </cfloop>

      <cfloop array="#arguments.right#" index="element">
        <cfif IsStruct(element) and StructKeyExists(element, arguments.id)>
          <cfset currentId = element[arguments.id]>
          <cfif StructKeyExists(lookup, currentId)>
            <cfloop collection="#element#" item="key">
              <cfset lookup[currentId][key] = Duplicate(element[key])>
            </cfloop>
          <cfelse>
            <cfset ArrayAppend(result, Duplicate(element))>
          </cfif>
        </cfif>
      </cfloop>

      <cfreturn result>

    </cffunction> 



    <cffunction name="keyWordsExtract" access="public" output="no" returntype="string">
        <cfargument name="html" required="yes" type="string">
        <cfset html = #Arguments.html#>
        <cfset matches = rematch("<shl>[^<]*</shl>", html)>
        <cfset results = ArrayNew(1)>
        <cfloop array="#matches#" index="match">
            <cfset output = arrayAppend(results, rereplace(match, "<shl>(.*)</shl>", "\1") )>
        </cfloop>

        <cfset keyWords = ArrayToList(results, ",")>
        <cfreturn keyWords>

    </cffunction> 

</cfcomponent>

Я уверен, что это проблема ColdFusion. Я боролся в течение нескольких недель, чтобы понять, что не так с приведенным выше кодом. Любой совет будет принята с благодарностью!

Спасибо

0 ответов

Другие вопросы по тегам