You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by vrajesh <vr...@gmail.com> on 2016/04/21 11:29:18 UTC

concat 2 fields

to concatenating two fields to use it as one field from
http://grokbase.com/t/lucene/solr-user/138vr75hvj/concat-2-fields-in-another-field 
,  
but the solution whichever is given i tried but its not working. please help
me on it.
 i am trying to concat latitude and longitude fields to make it as single
unit using following:
 <processor class="solr.ConcatFieldUpdateProcessorFactory"
                   <str name="field"attr_geo_lat</str>
                   <str name="field"attr_geo_long</str>
                    <str name="dest"geo_location</str>
                   <str name="delimiter",</str>
 </processor>
 i added it to solrconfig.xml.

 some of my doubts are :
 - should we define destination field (geo_location) in schema.xml?

 - i want to make this combined field  (geo_location) as field facet so i
have to add <str name="facet.field"geo_location</str>  in 

 - any specific tag in which i should add above process script to make it
working.




--
View this message in context: http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: concat 2 fields

Posted by vrajesh <vr...@gmail.com>.
i have tried two methods to define as follow:
1)
      <updateRequestProcessorChain name="concatFields">
		<processor class="solr.CloneFieldUpdateProcessorFactory"> 
			<str name="source">id</str> 
			<str name="dest">id_title</str> 
		</processor> 
		<processor class="solr.CloneFieldUpdateProcessorFactory"> 
			<str name="source">title</str> 
			<str name="dest">id_title</str> 
		</processor> 
		<processor class="solr.LogUpdateProcessorFactory" /> 
		<processor class="solr.RunUpdateProcessorFactory" />
	</updateRequestProcessorChain> 

2)
  <updateRequestProcessorChain name="concatFields">
    <processor class="solr.ConcatFieldUpdateProcessorFactory">
                  <str name="field">id</str>
                  <str name="field">title</str>
                   <str name="dest">id_title</str>
                  <str name="delimiter">,</str>
	</processor>
  </updateRequestProcessorChain> 
	

but none of them is working.

i am indexing using solr indexing portal :  
http://localhost:8983/solr/#/<corename>/documents

using above configuration i should get response with "id_title" as new field
in solr  :    http://localhost:8983/solr/ssp/select?q=*&wt=json&indent=true

but no such field found.



--
View this message in context: http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760p4272895.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: concat 2 fields

Posted by Reth RM <re...@gmail.com>.
Check if you have added the 'concatFields'  definition as well in
solrconfig.xml...
How are you indexing btw?


On Tue, Apr 26, 2016 at 12:24 PM, vrajesh <vr...@gmail.com> wrote:

> Hi,
> i have added it to /update request handler as per following in
> solrconfig.xml:
>  <requestHandler name="/update/json" class="solr.UpdateRequestHandler">
>         <lst name="defaults">
>          <str name="stream.contentType">application/json</str>
>                   <str name="update.chain">concatFields</str>
>        </lst>
>   </requestHandler>
>   <requestHandler name="/update/csv" class="solr.UpdateRequestHandler">
>         <lst name="defaults">
>          <str name="stream.contentType">application/csv</str>
>                   <str name="update.chain">concatFields</str>
>        </lst>
>   </requestHandler>
>
> but when i query it after indexing new files, i dont see any concatenated
> field.
>
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760p4272829.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: concat 2 fields

Posted by vrajesh <vr...@gmail.com>.
Hi,
i have added it to /update request handler as per following in
solrconfig.xml:
 <requestHandler name="/update/json" class="solr.UpdateRequestHandler">
        <lst name="defaults">
         <str name="stream.contentType">application/json</str>
		  <str name="update.chain">concatFields</str>
       </lst>
  </requestHandler>
  <requestHandler name="/update/csv" class="solr.UpdateRequestHandler">
        <lst name="defaults">
         <str name="stream.contentType">application/csv</str>
		  <str name="update.chain">concatFields</str>
       </lst>
  </requestHandler>

but when i query it after indexing new files, i dont see any concatenated
field.





--
View this message in context: http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760p4272829.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: concat 2 fields

Posted by Reth RM <re...@gmail.com>.
It should be added to /update request handler. All the others that you have
listed here are search request handlers, you should add this one to /update
RH.

On Mon, Apr 25, 2016 at 12:12 PM, vrajesh <vr...@gmail.com> wrote:

> in my solr config there are many requestHandler so i am confused in which
> requestHandler i should add it. i have some requestHandlers with names
> "/select", "/export","/query","/browse" and much more.
> i want to use this new processor chain for all type of file formats.
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760p4272564.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: concat 2 fields

Posted by vrajesh <vr...@gmail.com>.
in my solr config there are many requestHandler so i am confused in which
requestHandler i should add it. i have some requestHandlers with names
"/select", "/export","/query","/browse" and much more.
i want to use this new processor chain for all type of file formats.



--
View this message in context: http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760p4272564.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: concat 2 fields

Posted by Reth RM <re...@gmail.com>.
Have you added this new processor chain to update handler that you are
using(as shown below)?
 <str name="update.chain">myChain</str>

https://wiki.apache.org/solr/UpdateRequestProcessor#Selecting_the_UpdateChain_for_Your_Request



On Thu, Apr 21, 2016 at 2:59 PM, vrajesh <vr...@gmail.com> wrote:

> to concatenating two fields to use it as one field from
>
> http://grokbase.com/t/lucene/solr-user/138vr75hvj/concat-2-fields-in-another-field
> ,
> but the solution whichever is given i tried but its not working. please
> help
> me on it.
>  i am trying to concat latitude and longitude fields to make it as single
> unit using following:
>  <processor class="solr.ConcatFieldUpdateProcessorFactory"
>                    <str name="field"attr_geo_lat</str>
>                    <str name="field"attr_geo_long</str>
>                     <str name="dest"geo_location</str>
>                    <str name="delimiter",</str>
>  </processor>
>  i added it to solrconfig.xml.
>
>  some of my doubts are :
>  - should we define destination field (geo_location) in schema.xml?
>
>  - i want to make this combined field  (geo_location) as field facet so i
> have to add <str name="facet.field"geo_location</str>  in
>
>  - any specific tag in which i should add above process script to make it
> working.
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: concat 2 fields

Posted by vrajesh <vr...@gmail.com>.
Hi Jack,
as per your explanation i made following changes:
    <updateRequestProcessorChain name="concatFields">
		<processor class="solr.CloneFieldUpdateProcessorFactory"> 
			<str name="source">id</str> 
			<str name="dest">title</str> 
		</processor> 
		<processor class="solr.CloneFieldUpdateProcessorFactory"> 
			<str name="source">title</str> 
			<str name="dest">title</str> 
		</processor> 
		<processor class="solr.ConcatFieldUpdateProcessorFactory"> 
		<str name="fieldName">title</str> 
		<str name="delimiter">_</str> 
		</processor>
		<processor class="solr.LogUpdateProcessorFactory" /> 
		<processor class="solr.RunUpdateProcessorFactory" />
	</updateRequestProcessorChain> 

i.e trying to copy value of Id to Title field and then appending actual
Title field to make Id_Title combination.

but still it is not working. please help me if it can be done this way. 



--
View this message in context: http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760p4273072.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: concat 2 fields

Posted by Jack Krupansky <ja...@gmail.com>.
As I myself had commented on that grokbase thread so many months ago, there
are examples of how to do this is my old Solr 4.x Deep Dive book.

If you read the grokbase thread carefully, you will see that you left out
the prefix "Custom" in front of "Concat" - this is not a standard Solr
feature.

Concat simply combines multiple values for a single field into a single
value. It does that for each specified field independently. It will not
concatenate two separate fields.

What you can do is Clone your second field to the name of the first field,
which will result in two values for the first field. Then you can use
Concat to combine the two values.



-- Jack Krupansky

On Thu, Apr 21, 2016 at 5:29 AM, vrajesh <vr...@gmail.com> wrote:

> to concatenating two fields to use it as one field from
>
> http://grokbase.com/t/lucene/solr-user/138vr75hvj/concat-2-fields-in-another-field
> ,
> but the solution whichever is given i tried but its not working. please
> help
> me on it.
>  i am trying to concat latitude and longitude fields to make it as single
> unit using following:
>  <processor class="solr.ConcatFieldUpdateProcessorFactory"
>                    <str name="field"attr_geo_lat</str>
>                    <str name="field"attr_geo_long</str>
>                     <str name="dest"geo_location</str>
>                    <str name="delimiter",</str>
>  </processor>
>  i added it to solrconfig.xml.
>
>  some of my doubts are :
>  - should we define destination field (geo_location) in schema.xml?
>
>  - i want to make this combined field  (geo_location) as field facet so i
> have to add <str name="facet.field"geo_location</str>  in
>
>  - any specific tag in which i should add above process script to make it
> working.
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/concat-2-fields-tp4271760.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>