@ -1122,77 +1122,77 @@ public final class Protocol
// evaluate result
// evaluate result
List < URIMetadataNode > container = new ArrayList < URIMetadataNode > ( ) ;
List < URIMetadataNode > container = new ArrayList < URIMetadataNode > ( ) ;
if ( docList . size ( ) = = 0 ) {
if ( docList = = null | | docList . size ( ) = = 0 ) {
Network . log . logInfo ( "SEARCH (solr), returned 0 out of " + docList . getNumFound ( ) + " documents from " + ( target = = null ? "shard" : ( "peer " + target . hash + ":" + target . getName ( ) ) ) + " query = " + solrQuery . toString ( ) ) ;
Network . log . logInfo ( "SEARCH (solr), returned 0 out of " + docList . getNumFound ( ) + " documents from " + ( target = = null ? "shard" : ( "peer " + target . hash + ":" + target . getName ( ) ) ) + " query = " + solrQuery . toString ( ) ) ;
} else { // create containers
return 0 ;
Network . log . logInfo ( "SEARCH (solr), returned " + docList . size ( ) + " out of " + docList . getNumFound ( ) + " documents from " + ( target = = null ? "shard" : ( "peer " + target . hash + ":" + target . getName ( ) ) ) ) ;
}
Network . log . logInfo ( "SEARCH (solr), returned " + docList . size ( ) + " out of " + docList . getNumFound ( ) + " documents from " + ( target = = null ? "shard" : ( "peer " + target . hash + ":" + target . getName ( ) ) ) ) ;
int term = count ;
for ( final SolrDocument doc : docList ) {
if ( term - - < = 0 ) {
break ; // do not process more that requested (in case that evil peers fill us up with rubbish)
}
// get one single search result
if ( doc = = null ) {
continue ;
}
URIMetadataNode urlEntry = new URIMetadataNode ( doc ) ;
int term = count ;
if ( blacklist . isListed ( BlacklistType . SEARCH , urlEntry ) ) {
for ( final SolrDocument doc : docList ) {
if ( Network . log . isInfo ( ) ) {
if ( term - - < = 0 ) {
if ( localsearch ) {
break ; // do not process more that requested (in case that evil peers fill us up with rubbish)
Network . log . logInfo ( "local search (solr): filtered blacklisted url " + urlEntry . url ( ) ) ;
}
} else {
// get one single search result
Network . log . logInfo ( "remote search (solr): filtered blacklisted url " + urlEntry . url ( ) + " from " + ( target = = null ? "shard" : ( "peer " + target . hash + ":" + target . getName ( ) ) ) ) ;
if ( doc = = null ) {
continue ;
}
URIMetadataNode urlEntry = new URIMetadataNode ( doc ) ;
if ( blacklist . isListed ( BlacklistType . SEARCH , urlEntry ) ) {
if ( Network . log . isInfo ( ) ) {
if ( localsearch ) {
Network . log . logInfo ( "local search (solr): filtered blacklisted url " + urlEntry . url ( ) ) ;
} else {
Network . log . logInfo ( "remote search (solr): filtered blacklisted url " + urlEntry . url ( ) + " from " + ( target = = null ? "shard" : ( "peer " + target . hash + ":" + target . getName ( ) ) ) ) ;
}
}
}
continue ; // block with blacklist
}
}
continue ; // block with blacklist
}
final String urlRejectReason = Switchboard . getSwitchboard ( ) . crawlStacker . urlInAcceptedDomain ( urlEntry . url ( ) ) ;
final String urlRejectReason = Switchboard . getSwitchboard ( ) . crawlStacker . urlInAcceptedDomain ( urlEntry . url ( ) ) ;
if ( urlRejectReason ! = null ) {
if ( urlRejectReason ! = null ) {
if ( Network . log . isInfo ( ) ) {
if ( Network . log . isInfo ( ) ) {
if ( localsearch ) {
if ( localsearch ) {
Network . log . logInfo ( "local search (solr): rejected url '" + urlEntry . url ( ) + "' (" + urlRejectReason + ")" ) ;
Network . log . logInfo ( "local search (solr): rejected url '" + urlEntry . url ( ) + "' (" + urlRejectReason + ")" ) ;
} else {
} else {
Network . log . logInfo ( "remote search (solr): rejected url '" + urlEntry . url ( ) + "' (" + urlRejectReason + ") from peer " + target . getName ( ) ) ;
Network . log . logInfo ( "remote search (solr): rejected url '" + urlEntry . url ( ) + "' (" + urlRejectReason + ") from peer " + target . getName ( ) ) ;
}
}
}
continue ; // reject url outside of our domain
}
}
continue ; // reject url outside of our domain
}
// passed all checks, store url
// passed all checks, store url
if ( ! localsearch ) {
if ( ! localsearch ) {
try {
try {
event . query . getSegment ( ) . fulltext ( ) . putDocument ( ClientUtils . toSolrInputDocument ( doc ) ) ;
event . query . getSegment ( ) . fulltext ( ) . putDocument ( ClientUtils . toSolrInputDocument ( doc ) ) ;
ResultURLs . stack (
ResultURLs . stack (
ASCII . String ( urlEntry . url ( ) . hash ( ) ) ,
ASCII . String ( urlEntry . url ( ) . hash ( ) ) ,
urlEntry . url ( ) . getHost ( ) ,
urlEntry . url ( ) . getHost ( ) ,
event . peers . mySeed ( ) . hash . getBytes ( ) ,
event . peers . mySeed ( ) . hash . getBytes ( ) ,
UTF8 . getBytes ( target . hash ) ,
UTF8 . getBytes ( target . hash ) ,
EventOrigin . QUERIES ) ;
EventOrigin . QUERIES ) ;
} catch ( final IOException e ) {
} catch ( final IOException e ) {
Network . log . logWarning ( "could not store search result" , e ) ;
Network . log . logWarning ( "could not store search result" , e ) ;
continue ; // db-error
continue ; // db-error
}
}
}
// add the url entry to the word indexes
container . add ( urlEntry ) ;
}
}
if ( localsearch ) {
// add the url entry to the word indexes
event . add ( container , facets , snippets , true , "localpeer" , ( int ) docList . getNumFound ( ) ) ;
container . add ( urlEntry ) ;
event . rankingProcess . addFinalize ( ) ;
}
event . addExpectedRemoteReferences ( - count ) ;
Network . log . logInfo ( "local search (solr): localpeer sent " + container . get ( 0 ) . size ( ) + "/" + docList . size ( ) + " references" ) ;
if ( localsearch ) {
} else {
event . add ( container , facets , snippets , true , "localpeer" , ( int ) docList . getNumFound ( ) ) ;
event . add ( container , facets , snippets , false , target . getName ( ) + "/" + target . hash , ( int ) docList . getNumFound ( ) ) ;
event . rankingProcess . addFinalize ( ) ;
event . rankingProcess . addFinalize ( ) ;
event . addExpectedRemoteReferences ( - count ) ;
event . addExpectedRemoteReferences ( - count ) ;
Network . log . logInfo ( "local search (solr): localpeer sent " + container . get ( 0 ) . size ( ) + "/" + docList . size ( ) + " references" ) ;
Network . log . logInfo ( "remote search (solr): peer " + target . getName ( ) + " sent " + container . get ( 0 ) . size ( ) + "/" + docList . size ( ) + " references" ) ;
} else {
}
event . add ( container , facets , snippets , false , target . getName ( ) + "/" + target . hash , ( int ) docList . getNumFound ( ) ) ;
}
event . rankingProcess . addFinalize ( ) ;
event . addExpectedRemoteReferences ( - count ) ;
Network . log . logInfo ( "remote search (solr): peer " + target . getName ( ) + " sent " + container . get ( 0 ) . size ( ) + "/" + docList . size ( ) + " references" ) ;
}
return docList . size ( ) ;
return docList . size ( ) ;
}
}