Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Intersection.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Intersection.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Intersection.java	(revision 3162)
@@ -146,7 +146,7 @@
 						
 						if (subcorpus == null) {
 							monitor.done();
-							System.out.println(TXMUIMessages.errorColonSubcorpusWasNotCreated);
+							Log.warning(TXMUIMessages.errorColonSubcorpusWasNotCreated);
 							return Status.CANCEL_STATUS;
 						}
 						
Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Union.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Union.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Union.java	(revision 3162)
@@ -146,7 +146,7 @@
 						
 						if (subcorpus == null) {
 							monitor.done();
-							System.out.println(TXMUIMessages.errorColonSubcorpusWasNotCreated);
+							Log.warning(TXMUIMessages.errorColonSubcorpusWasNotCreated);
 							return Status.CANCEL_STATUS;
 						}
 						
Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Substraction.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Substraction.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Substraction.java	(revision 3162)
@@ -145,12 +145,12 @@
 						
 						if (subcorpus == null) {
 							monitor.done();
-							Log.info(TXMUIMessages.errorColonSubcorpusWasNotCreated);
+							Log.warning(TXMUIMessages.errorColonSubcorpusWasNotCreated);
 							return Status.CANCEL_STATUS;
 						}
 						
 						if (subcorpus.getSize() == 0) {
-							Log.info("The created subcorpus was empty");
+							Log.warning("The created subcorpus was empty");
 							return Status.CANCEL_STATUS;
 						}
 						
Index: tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java	(revision 3162)
@@ -195,7 +195,7 @@
 						
 						if (subcorpus == null) {
 							monitor.done();
-							Log.severe(TXMUIMessages.errorColonSubcorpusWasNotCreated);
+							Log.warning(TXMUIMessages.errorColonSubcorpusWasNotCreated);
 							return Status.CANCEL_STATUS;
 						}
 						
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java	(revision 3162)
@@ -541,6 +541,11 @@
 		
 		long start = System.currentTimeMillis();
 		try {
+			if (query.getQueryString().length() > CQLQuery.MAX_CQL_LENGTH) {
+				Log.warning(NLS.bind("Error: CQL length limit reached ({0}) with the {1} length.", CQLQuery.MAX_CQL_LENGTH, query.getQueryString().length())); 
+				return null;
+			}
+			
 			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getQualifiedCqpId(), subcorpusCqpId, CQLQuery.fixQuery(query.getQueryString()));
 			// System.out.println("SUBCORPUS: "+subcorpusCqpId+"
 			// q="+query.getQueryString());
@@ -1429,6 +1434,17 @@
 		String queryResultId = queryResultNamePrefix + getNextQueryCounter();
 		String fixedQuery = CQLQuery.fixQuery(query.getQueryString());
 		
+		if (fixedQuery.length() > CQLQuery.MAX_CQL_LENGTH) {
+			try {
+				Log.warning(NLS.bind("Error: CQL length limit reached ({0}) with {1} length.", CQLQuery.MAX_CQL_LENGTH, fixedQuery.length())); 
+				return new FakeQueryResult(queryResultName, this, query, new int[0], new int[0], new int[0]);
+			}
+			catch (InvalidCqpIdException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		
 		Log.finest(NLS.bind(TXMCoreMessages.queryOnP0ColonP1InfP2, new String[] { this.getQualifiedCqpId(), queryResultId, fixedQuery })); // $NON-NLS-1$
 		// long start = System.currentTimeMillis();
 		try {
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 3162)
@@ -126,6 +126,10 @@
 		if (this.pQuery != null) {
 			this.qresult = null; // reset
 			String parent_id = this.getCorpusParent().getQualifiedCqpId();
+			if (pQuery.getQueryString().length() > CQLQuery.MAX_CQL_LENGTH) {
+				Log.warning(NLS.bind("Error: CQL length limit reached ({0}) with {1} length.", CQLQuery.MAX_CQL_LENGTH, pQuery.getQueryString().length())); 
+				return false;
+			}
 			CorpusManager.getCorpusManager().getCqiClient().cqpQuery(parent_id, this.pID, CQLQuery.fixQuery(this.pQuery.getQueryString()));
 			
 			this.qresult = new QueryResult(this.pID, this.getUserName(), this.getCorpusParent(), this.pQuery); // getCorpusParent().query(pQuery, this.pID, true);
@@ -176,7 +180,7 @@
 				}
 				catch (Exception ex) {
 					Log.warning(this.pID + TXMCoreMessages.failedToRestoreSubcorpus + subcorpusElem.getAttribute("name")
-							+ " : " + ex); //$NON-NLS-1$
+					+ " : " + ex); //$NON-NLS-1$
 				}
 			}
 			
@@ -279,7 +283,7 @@
 			return 0;
 		}
 	}
-		
+	
 	// protected void finalize() throws Throwable {
 	// try {
 	// //
@@ -407,7 +411,7 @@
 	
 	@Override
 	public int[] getStartLimits(String sup) throws IOException,
-			CqiServerError, InvalidCqpIdException, CqiClientException {
+	CqiServerError, InvalidCqpIdException, CqiClientException {
 		return this.getMainCorpus().getStartLimits(sup);
 	}
 	
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/CQLQuery.java	(revision 3162)
@@ -61,6 +61,8 @@
 	
 	/** The Constant ElectricStrategy. */
 	private static final Integer ElectricStrategy = 3;
+
+	public static final int MAX_CQL_LENGTH = 16000; // current CQL length limit is set to ~16000. The corpus name will affect the query limit length
 	
 	
 	/** espace char |"{()}+*. */
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/QueryResult.java	(revision 3162)
@@ -424,7 +424,7 @@
 	
 	@Override
 	public boolean isTargetUsed() throws UnexpectedAnswerException, IOException, CqiServerError {
-		
+
 		return CQPSearchEngine.getCqiClient().subCorpusHasField(this.getQualifiedCqpId(), ICqiClient.CQI_CONST_FIELD_TARGET);
 	}
 	
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPLexicon.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPLexicon.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPLexicon.java	(revision 3162)
@@ -39,12 +39,14 @@
 import java.util.Map;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osgi.util.NLS;
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.core.results.TXMParameters;
 import org.txm.core.results.TXMResult;
 import org.txm.searchengine.cqp.AbstractCqiClient;
 import org.txm.searchengine.cqp.ICqiClient;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.query.CQLQuery;
 import org.txm.searchengine.cqp.corpus.query.MatchUtils;
 import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.utils.TXMProgressMonitor;
@@ -262,7 +264,10 @@
 			try {
 				// System.out.println("subcorpus: "+corpus.getQualifiedCqpId());
 				// System.out.println("query subcorpus: "+qtmp);
-
+				if (tmp.length() > CQLQuery.MAX_CQL_LENGTH) {
+					Log.warning(NLS.bind("Error: CQL length limit reached ({0}) with {1} length.", CQLQuery.MAX_CQL_LENGTH, tmp.length())); 
+					return false;
+				}
 				cqi.cqpQuery(corpus.getQualifiedCqpId(), tmp, "[]"); //$NON-NLS-1$
 				fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(qtmp, 0, ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
 				// System.out.println("nb lines: "+fdist.length);
Index: tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java
===================================================================
--- tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java	(revision 3161)
+++ tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java	(revision 3162)
@@ -2,7 +2,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.List;
 
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -20,10 +19,8 @@
 import org.txm.searchengine.core.Selection;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
-import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages;
 import org.txm.searchengine.cqp.corpus.CQPCorpus;
 import org.txm.searchengine.cqp.corpus.CorpusManager;
-import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.searchengine.cqp.corpus.WordProperty;
 import org.txm.searchengine.cqp.corpus.query.CQLQuery;
