Question: I have a requirment where I have to match a substring in a query .
e.g if the field has value : 

> 
> PREFIXabcSUFFIX
> 
> 
> 

I have to create a query which matches `abc`. I always know the length of the prefix. 

I can not use `EdgeNgram` and `Ngram` because of the space constraints.(As they will create more indexes.) 

So i need to do this on query time and not on index time. Using a wildcard as prefix something like `*abc*` will have high impact on performance . 

Since I will know the length of the prefix I am hoping to have some way where I can do something like `....abc*` where dots represents the exact length of the prefix so that the query is not as bad as searching for the whole index as in the case of wild card query (`*abc*`).

Is this possible in solr ? Thanks for your time .

Solr version : 4.10

Answer: 
Sure, Wildcard syntax is [documented here](https://lucene.apache.org/core/4_10_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#Wildcard_Searches), you could search something like `????abc*`. You could also use a regex query.

However, the performance benefit from this over `*abc*` will be very small. It will still have to perform a sequential search over the whole index. But if there is no way you can improve your analysis to support your search needs, there may be no getting around that ([GIGO](https://en.wikipedia.org/wiki/Garbage_in,_garbage_out)).
You could use [the RegularExpressionPatternTokenizer](https://cwiki.apache.org/confluence/display/solr/Tokenizers#Tokenizers-RegularExpressionPatternTokenizer) for this. For the sample below I guessed that the length of your prefix is 6. Your example text `PREFIXabcSUFFIX` would become `abcSUFFIX`. This way you may search for `abc*`

```xml
<analyzer>
  <tokenizer class="solr.PatternTokenizerFactory" pattern=".{6}(.+)" group="1"/>
</analyzer>

```

About the Tokenizer:

> 
> This tokenizer uses a Java regular expression to break the input text stream into tokens. The expression provided by the pattern argument can be interpreted either as a delimiter that separates tokens, or to match patterns that should be extracted from the text as tokens.
> 
> 
>